We help IT Professionals succeed at work.

C# how to determine type on previous page

zintech asked
I have a .aspx page that has radio buttons and a drop down list.  What I am doing is filling the data source for the drop down list in the page's "OnPreRenderComplete" method.  The AutoPostBack properties of both the drop down list and radio buttons is set to True, which causes the page to reload when either is changed.  In the OnPreRenderComplete method, I want to select the value of what sohuld be selected in the drop down list, but ONLY if the selected radio button is what triggered the page to be refreshed.

My question is this: how do I determine in the OnPreRenderComplete method what the event was that triggered the page to reload?
Watch Question

Most Valuable Expert 2011
Top Expert 2015
You can query the "__EVENTTARGET" parameter that comes back in the request:

if (IsPostBack && Request.Params["__EventTarget"].StartsWith(RadioButtonList1.ID))
    Response.Write("Good trigger!");

Open in new window