How can I block postback caused by an ASP.NET Button (or, any other) server control?
I.e. I shall push a Button but no postback will occur.
How can I block postback caused by an ASP.NET Button (or, any other) server control?
I.e. I shall push a Button but no postback will occur.
do this
button.Attributes.Add("onclick", "return false;")
on page load.
you could use the
OnClientClick="return false;"
property of the button
You could use AJAX controls that do callbacks instead of postbacks for another possibility besides the Javascript "return false;" answer.
You can make the client side validation fail for the control's validation group. Depending on what you're trying to do, that might be a nicer solution.
You can piggyback on the JavaScript run for each postback as well, but showing you from the top of my head while typing on a mobile phone... maybe not. I'll update this post when I get home.