5

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.

Vaibhav Jain
  • 33,887
  • 46
  • 110
  • 163

3 Answers3

8

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

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

mamoo
  • 8,156
  • 2
  • 28
  • 38
1

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
  • 939
  • 1
  • 7
  • 13
  • 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 May 14 '10 at 13:12
0

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
  • 19,710
  • 36
  • 144
  • 222