I am currently developing a web site using ASP.NET 3.5. On a page there are some situations I don’t want that a specific control will cause a postback to the server. I wrote a function to return false if that condition is met which will be called when the onsubmit-Event occurs. But I somehow need to determine which control will cause the postback, because the postback should be cancelled only if this specific control caused it under certain conditions. How it is possible to do that?
Thanks for your time.
See:
this is from here – The Client Side of ASP.NET Pages.
So at the client-side
__EVENTTARGETis all you need. At the server-side you could either override thePage.RaisePostBackEventmethod (this is protected method, so you could inherit fromSystem.Web.UI.Pageclass):or perform the same without inherining:
EDIT: regarding the author’s comment to my answer: if
__EVENTTARGETvalue is an empty string, it seems you’re getting this value before it is been set in__doPostBackfunction. So the workaround could be in overriding__doPostBackfunction or a similar way; you could find an example of doing it in this SO quesion.