Using jQuery div click - call c# method

Mar 10 2015 5:28 PM
I'm trying to call an onClick from my LinkButton, when i click the div.content2, can anyone tell me, what i'm doing wrong?
The reason i'm trying to do it this way, is that i already have a function on this div, and i think it would be "nicer" if it all happened at once. 

This is my HTML: 
<asp:LinkButton ID="lnkUpdate" runat="server" OnClick="setRead_Click" CommandName='<%# Eval("MessageID") %>' Visible="true" Text='<%# Eval("MessageID") %>' />
<div class="container2">
        <div id="read" runat="server" class="header2">
                <span>Expand</span>
        </div>
        <div class="content2">
                <div class=" m-t-sm">
                        <asp:Label ID="lblMessage" runat="server" Text='<%# Eval("Message") %>' />
                </div>
        </div>
</div>

This is my jQuery script: 
<script>
        $(".header2").click(function () {
                $("#lnkUpdate").click();
                $header2 = $(this);
                $content2 = $header2.next();
                $content2.slideToggle(500, function () {
                        $header2.text(function () {
                                return $content2.is(":visible") ? "Collapse" : "Expand";
                        });
                });
         });
</script> 

Answers (5)