Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET jQuery
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.
 

 
$(document).ready(function(){
  $("#button1").click(function() {
     alert('welcome to Jquery');
 
    });
 
});
 
 <asp:Button ID="Button1" runat="server" Text="Button" />
Posted 21-Feb-13 3:32am
Comments
Sandeep Mewara at 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?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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:button id="Button1" runat="server" text="Button" xmlns:asp="#unknown" /> 
$(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 )..
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 7,215
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
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