page-lifecycle

What do you do when you can't use ViewState?

I have a rather complex page that dynamically builds user controls inside of a repeater. This repeater must be bound during the Init page event before ViewState is initialized or the dynamically created user controls will not retain their state. This creates an interesting Catch-22 because the object I bind the repeater to needs to be c...

ASP.net - How can one differentiate Page-Processing Time from Client-Transmission Time

The single timing column in the weblog naturally includes client transmission timing. For anamoly analysis, I want to differentiate pages that took excessive construction time from requests that simply had a slow client. For buffered pages, I've looked at the ASP.NET page lifecycle model and do not see where I can tap in and codewise m...

In ASP.Net, during which page lifecycle event does viewstate get loaded?

I know it happens sometime before Load, but during what event exactly? ...

At which point in the lifecycle does GetConnectionInterface get called?

I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer("Filter Data Consumer")] public void GetConnectionInterface(IFilterData filterData) { _filterData = filterData; } Now, before I can call upon _filterData, I need to know when i can expect it to not be null. When is this?! Without knowin...

How do I - in ASP.NET save the info from a page when a user leaves the page?

In our CMS, we have a place in which we enable users to play around with their site hierarchy - move pages around, add and remove pages, etc. We use drag & drop to implement moving pages around. Each move has to saved in th DB, and exported to many HTML files. If we do that in every move, it will slow down the users. Therefore we thou...

Visual Studio: Automatically re-order page events according to the ASP.NET Page LifeCycle?

What would be the easiest way to re-order existing page events according to the ASP.NET Page LifeCycle? I'm trying to make my events more readable and maybe make it easy to scroll into a sequentially near event. If there's no easy way, is there a non-mouse way to quickly switch to a page event without having to type the actual event i...

ASP.NET Repeater ItemDataBound happening AFTER PreRender event?

I have a repeater control on an ASP.NET 2.0 web form. As I understanding it, all of the page's data-bound controls fire their binding events somewhere in between the Page_Load and the Page_PreRender events. However, my repeater's ItemDataBound event appears to be happening AFTER the PreRender event. How is this so and is there any ...

Display Ajax Loader while page rendering

This is probably a simple question but how can I best use an AJAX loader in ASP.NET to provide a loading dialog whilst the page is being built? I currently have an UpdatePanel with an associated UpdateProgressPanel which contains the loading message and gif in a ProgressTemplate. Currently I have a page that onLoad() goes and gets the...

Am I supposed to be able to alter other controls from an ASP.NET page event handler?

Hi, I'm trying to disable a label control from the CheckedChanged event handler of a checkbox. Should I be able to do this? At the moment if I set Enabled to false nothing changes when the page reloads. If I do the same thing in Page_Load then I see the change. To clarify: This doesn't work: protected void chkNeverExpires_CheckedChan...

On which Page life cycle are the Client IDs generated?

i am programatically adding Webcontrols in to a User Control i am also adding a javascript event passing the controlID as a parameter but the clientID is the one i assigned a it does not contain the one that asp.net generates var txt = new TextBox(); txt.ID = "MyID"+Number; chkBox.Attributes.Add("onClick", "EnableTxtBox('" +tx...

Is it acceptable to keep a db connection open for the life of the page?

Everybody knows that you should close a connection immediately after you finish using it. Due to a flaw in my domain object model design, I've had to leave the connection open for the full page life cycle. Essentially, I have a Just In Time property which opens a connection on first call, and then on Page.Unload (..) it would check if ...

Do I need to unsubscribe from (manually subscribed to) events in asp.net?

Do the same best practis rules regarding subscribing/unsubscribing to events apply in asp.net? I know it might seem like a silly question, but when I think about it, I have never really seen any code where people first subscribe to an event on a page and then unsubscribe later on in the web request. Example 1: On a page, in the Page_Lo...

ASP.NET event order during postback or initial request

Could I get some confirmations from the community that I'm not going mad, and that the life cycle of a page during post back is in deed in a different order to when the page is initally requested. If this is the case pointers towards references/articles outlining the order would be greatly appreciated. (A postback equivalent of the pag...

handle event before Page_Load

I have an asp.net web page with a ton of code that is handled in the Page-Load event of the page. I also have a dropdown box on the page that should reload the page with a new value, but I would like to get this new value before I process the entire Page-Load code. I am trying to get my head around ASP.NET page lifecycle. Should I mov...

Server-Side-Code in aspx file

Hi all, I want to ask in which phase of Control Execution Lifecycle is the "Server-Side-Code written in aspx file" being executed? Is it before SaveState or after, I claim it's in the rendering phase, is it true?? in aspx file if my code writen as "<%" if(true) { rdlistAnswers.Items.Clear(); foreach (string item in myCollection) { ...

ASP.NET Preload Post Back Event

Is there any kind of event out there that would allow for a preload post back event. The reason I ask is I have a control that adds sibling controls to it on postback events, however, by the time it has loaded the post back its too late to add the new control to the control collection. Therefore, the controls are never updated correc...

At what point should I call base methods of ASP.NET events?

In ASP.NET, if I override a page lifecycle event, should I call its base method before or after doing my work? Does it even matter? protected override void OnPreRender(EventArgs e) { // My code goes here base.OnPreRender(e); // Or here } ...

ASP.Net Object Data Source - Data Binding

At what point does a ASP.Net Object Data Source bind data, from the specified data source, in the page life cycle? ...

ASP.NET page events - Button click event comes after GridView bind

My understanding of the order of page events is this: Page : Load Control : DataBind (for a GridView or whatever) Control : Load Control : Clicked (for a Button) Page: PreRender Control : PreRender (There are lots of others - but these are the ones I'm interested in) The important thing to notice here is t...

ASP.NET Post Application_Error Event

I'm trying to find an event that will fire immediately after all Application_Error event handlers so that I can modify the response sent (messing with the status code and 'location' headers and creating a new body specifically) using a custom HttpModule. I've tried hooking into Application_EndRequest (as I've read that this is the only ...