5) Using the Context object
(06/23/02)
This idea was submitted to me by Kirk Jackson, Thanks!
The context object is a variable that is initalized at the start of each request and will last until the end of the request. You can store items in this object and then transfer the page using Server.Transfer.
Page 1 -
<script language="VB" runat="server"> Sub Do_page1(sender as object, e as EventArgs) Context.Items("Name") = name.Text Server.Transfer("mpf9.aspx") End Sub </script> <form runat="server"> Enter your name: <asp:textbox id="name" runat="server" /><br> <asp:button text="Next Page" runat="server" OnClick="Do_page1" /> </form> |
This would store it and sent it along.
Last Page
Thanks <%=Context.Items("Name")%>, I hope it's nice in <%=Context.Items("City")%>. |
Summary
Well, you have learnt the ways to work-around that annoying 'Always-post-back' problem in ASP.NET