Need help regarding query string in asp.net

送分小仙女□ 提交于 2019-12-07 06:30:25

问题


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.


回答1:


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

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




回答2:


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




回答3:


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 
     }

}


}


来源:https://stackoverflow.com/questions/2826958/need-help-regarding-query-string-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!