When a button is clicked, I would lik开发者_如何学Pythone to check whether a button is clicked in my page_load. Is this possible? I am using asp.net 2.0 C#
You can check the IsPostBack
flag to see if it was a postback rather than an initial load. This may be what you're after. Also, you can check the Request.Form["__EVENTTARGET"]
from which you can obtain information about the control that raised the event and therefore find out if it was one of your buttons from there.
The button click event will fire after the page load event has. That being said, you can always check the http header to see what value is being pushed back through the request.form event. The button id will be in there if it has been fired.
I can think a work around by creating a hidden field and changing the value when a certain button is clicked and checking it value in Page_Load.
精彩评论