Form Tips - Forcing a Form.Load event to fire when coming back to same form
Categories: Browser Navigation, Browser Refresh & Suspend
|
Tags: Architects, Developers, Navigation, 2. Intermediate, 3. Advanced, Navigation, ASP.NET, v6.3, v6.4 and Later
Revision:
1
Posted:
11/Oct/2009
Updated:
24/May/2010
Status:
Publish
Types: Article
|
OverviewThink of a scenario where you have two forms in your application, Form1 and Form2. You register a Form1.Load and Form2.Load event handler, where you do some initializing necessary for your form. You open your browser and open Form1.wgx and you get Form1.Load event firing and do it's work. Now you redirect to Form2.wgx (changing browser's address bar for instance) and you get Form2.Load event firing. Finally you redirect back to Form1.wgx, and your Form1.Load event does not fire in that case. The reason lies in the fact that when you come back to Form1, you are within the same session and there is allready a Context available for Form1 (provided you come back within the timeout limits), so no new context is created and hence no Load event is fired, as it fires a part of a new Context being created. Possible solutionsDetecting when you go to another pageBy registering to the Application.ThreadSuspend event, you can make sure you destroy the Context of Form1 before leaving it.
Samples of useMaking your form statelessBy making the Form requiring the Load event to be fired as stateless, you will force the Load event to fire every time it is visited. A testing is recommended in this case as this might have complications. Forum ThreadsIssuesUsing vwginstance and an instance counterSamples of useRedirecting with unique query stringsBy redirecting to the new form and make each redirect use a unique query string, you will force the Form.Load event to fire every time. The redirect could for instance be of the form http://someapp?requestid=xxx where you make sure xxx is a unique number. A special case of using a unique query strings would be to use the "vwgInstance" query string variable. The value of this parameter is numeric and begins with the value "1" which is the default. Every consecutive new context that is opened on the session gets a number that is inceremented by 1. This will not only force the Load event to fire, but will create a new context that your form will run in.
Forum threads IssuesReferencesArticles
About the author
Related Articles
|
Browser Navigation
|
|
|
This sample code demonstrate how to add support for the browser's Back/Forward/Refresh buttons.
Tags:
Developers, Events, Navigation, 1. Beginner, 2. Intermediate, Navigation, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
Tags:
Architects, Developers, Navigation, Windows & Dialogs, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Developers, Events, Navigation, 1. Beginner, 2. Intermediate, Navigation, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
Tags:
Developers, Events, Windows & Dialogs, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
|