Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to call toggle function of j query on each click of button

so i used this code

$("[id*=btnAwesome]").live("click", function() {
       return false;

but this code disable my asp buttons post back so i cant executecode behind

i want such code which help in both
calling j query on each click and also post back

1 solution

you used Return False this thing stopping page from postback on button click.

try this example--(include jquery 1.4.1)

<head runat="server">

    <script type='text/javascript' src="jquery-1.4.1.min.js">

    <style type="text/css">
            display: none;

    <script type="text/javascript">
        $(function() {
            $("#Link1").click(function(evt) {
                if ($('#panelText').hasClass('panel')) {
                    $('#PanelState').attr('value', 'true');
                } else {
                    $('#PanelState').attr('value', 'false');

        $(document).ready(function() {
            if ($('#PanelState').attr('value') == 'false') {

    <form id="form1" runat="server">
    <asp:hiddenfield id="PanelState" runat="server" value="false"  />
    <asp:hyperlink id="Link1" runat="server" navigateurl="#" >SlideToggle
    </asp:hyperlink><br />
    <asp:panel id="panelText" runat="server" >
        Some text</asp:panel>
    <asp:button id="button1" runat="server" text="Postback"  />
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900