Click here to Skip to main content
12,695,044 members (33,822 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
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
Posted 21-Dec-12 8:01am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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"  />

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100