onpreinit

Where should I implement functionality in Page object - constructor or OnPreInit?

Hello all, A question I have been thinking about for a while - would Stackoverflow users commonly implement significant functionality in a constructor (specifically in classes derived from the System.Web.UI.Page class) , or should we keep the logic here as simple as possible and instead implement functionality in OnPreInit (using the co...

If I cannot use OnPreInit in Controls, how can I add my controls dynamically on the right time?

Hi, I want to have a user control which will add some checkboxes in a asp.NET panel dynamically. Simply I was believing I can do that easily in control's OnPreInit method. But the thing is I have learn that I cannot use and override OnPreInit method on Controls; it is only used for pages. I do not want to solve this from the page by c...

ASP.NET MVC 1.0 Nested Masterpages

Hi, I have a problem with my master pages. They have such inheritance order: MainMaster1.Master can be nested by Nested1.Master, Nested2.Master, etc. At the same time MainMaster can be duplicated and have working copies like MainMaster2, MainMaster3, etc. Advise please how can I dynamically change the MasterPageFile of my Nested1, Nes...

Converting ASP.Net Web Form to User Control OnPreInit event

I'm in the process of converting an ASP.Net webform into a User control and there an event that now says no suitable method found to override the event code causing the compile error protected override void OnPreInit(EventArgs e) { //do some stuff base.OnPreInit(e); } Is there any equivalent for a user control? ...

How do I avoid persisting data through ViewState for a child control in ASP.NET?

I have a control (say, a DataGrid or a ComboBox) which is a child of a user control. I want to DataBind it on every request, rather than have it's state persist through ViewState. I need to leave EnableViewState=true however. This means, I think, that I need to call DataBind before TrackViewState() is called. I read the fantastic blo...

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. ...

Override strongly typed @page masterpagefile

Hi, I am working with a third party asp.net application that uses master pages and nested master pages. My needs are to dynamically set the master page files for each page(.aspx). The application by default sets the master page file in the strongly typed @Page directive for each page. I don't want to change the strongly typed directiv...