Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a problem when i use JQuery in aspx page,Page is post packing . i have written Jquery alert message on button click. when i click the button, my page is post packing. i got a solution for my problem.
(add return false; end of alert message.)
Is there any other solution for stop postpacking when call jquery function on button click.



C#
$(document).ready(function(){
  $("#button1").click(function() {
     alert('welcome to Jquery');

    });

});


<asp:Button ID="Button1" runat="server" Text="Button" />
Posted
Comments
Sandeep Mewara 21-Feb-13 8:51am    
Is there any other solution for stop postpacking when call jquery function on button click.
What exactly is your need? Sounds like you have a solution but don't want to use it. Why?

Hii professional

these some link that will help you....

http://stackoverflow.com/questions/2879175/disable-buttons-on-post-back-using-jquery-in-net-app[^]

http://stackoverflow.com/questions/14755731/asp-net-jquery-button-click-prevent-postback[^]

if have any problem with it then please share here.......


Happy to help.
 
Share this answer
 
Important thing you should know while using Jquery is PostBack property
When postback occurse JQuery code will get its original values..
So you should prevent postback to see the functionality of it..

ASP.NET
<asp:button id="Button1" runat="server" text="Button" xmlns:asp="#unknown" />

JavaScript
$(document).ready(function () {
            $("#Button1").click(function (e) {
                $("#panel").slideToggle("slow");// Your code on button click
                 e.preventDefault();
                });
 
   });


Where e.preventDefault() will avoid paostback.. So when you are using buttons use e.preventDefault() to prevent postback ( If postback is no necessory )..
 
Share this answer
 
v2

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