onpreinit

How to work with Master Page that is attached to the page via the page's basepage?

一世执手 提交于 2019-12-11 02:18:49
问题 In my ASP.Net web application, I have a base page that implements functionality that spans all pages of the web application and my web pages derive from this base page. Since there is a single master page for the entire website, I don't want to attach the master page in each of the web pages. So I attached the Master page via the basepage's OnPreInit method as follows: protected override void OnPreInit(EventArgs e) { this.MasterPageFile = "~/Site.master"; base.OnPreInit(e); } However, when I

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.