Need help regarding query string in asp.net
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.
Probably the best choice is to handle them on Page_Load event:
http://msdn.microsoft.com/en-us/library/ms178472.aspx#lifecycle_events
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
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
}
}
}
精彩评论