Finding events to be processed in ASP.NET
On PostBack, from clicking on an ImageButton, it first hits
protected void Page_Load(object sender, EventArgs e)
Then it hits
protected void ImageButton_Click(object sender, EventArgs e)
My problem is that in my Page_Load it refreshes a ListBox before the selected items can be processed by ImageButton_Click.
Is there a way to tell what events are yet to be processed, so I can h开发者_运维技巧andle them?
Populate/databind your ListBox within Page_Load only on the first load, not after postback. Viewstate will maintain the items in your ListBox subsequently.
protected void Page_Load(object sender, EventArgs e) {
if(!IsPostBack) //if not postback
{
//populate your listbox
}
}
Here's a good read on the Page's Lifecycle, you'll understand the sequence/order of page/child-controls' events and their purposes.
http://msdn.microsoft.com/en-us/library/ms178472.aspx
精彩评论