views:

110

answers:

3

I have a page create-quote.aspx. I want to open this page in different modes, depending on whether a querystring parameter is present or not.

My question is at which event should I check, If I have a querystring parameter or not. I think, it should be preinit, what do you say.

+6  A: 

Probably the best choice is to handle them on Page_Load event:

http://msdn.microsoft.com/en-us/library/ms178472.aspx#lifecycle_events

mamoo
+1 for the useful link
Toby
Really a useful link.
vaibhav
A: 

You're correct. You should check the querystring in the preinit event. Before the Initialzation there is a start fase where the request en response objects are created.

Reference: http://msdn.microsoft.com/en-us/library/ms178472.aspx

Tim
You CAN check in the preinit but it depends on what you want to do as to whether it is useful to check at this stage. If you wanted to set values on controls, e.g. make panels visible and invisible you could not do that yet, all you could do is set some property and then later on set the panels based on the value in the property. If this is what you are ging to do you might as well check the values at the time when you can do something with them.
Ben Robinson
A: 

I would check that in the Page_Load event something like this:

Page_Load  {

if(!Page.IsPostback) 
{


    if(Request.QueryString["id"] != null) 
     {
        // do whatever with the id value 
     }

}


}
azamsharp