Techniques To Send Data From One Webform To Another In Asp.net Part 58


Text version of the video

Slides

All ASP .NET Text Articles

All ASP .NET Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

Different techniques to move data from one webform to another
1. Cross Page Postback: Discussed in Part 55 and Part 56
2. Context.Handler object – Will be discuss in this video session.

The following concepts will be discussed in the subsequent sessions
3. Query strings
4. Cookies
5. Session state
6. Application state

In general, the members of one Web form are unavailable from a subsequently displayed Web form. However, when navigating between Web forms using the Transfer or Execute method, data can be retrieve from the previous Web form using Context.Handler object.

Points to remember Context.Handler object
1. Context.Handler returns WebForm1 as the previous page, only the first time when you land on WebForm2 from WebForm1. If there is a button on WebForm2, and if you click the button, the page will postback, and Context.Handler will return WebForm2 instead of WebForm1.
2. For the Context.Handler to return WebForm1 as the previous page, you should have landed on WebForm2, using Server.Transfer or Server.Execute method from WebForm1.
3. The control values from the previous page, can be accessed using FindControl() method or using public properties. The problem with FindControl() method is that, if you mis-spell the ControlID, we could get a runtime NullRefernceException. Using public properties, instead of FindControl() method, can eliminate runtime NullRefernceExceptions.