First of all, you should understand the web application is
completely different from windows application. It's so
called stateless that means once you move from one page to
another page the first page is disappeared. You can't
refer to it and of course, can't get any data from it.
When you go back to the first page, it actually re-
initializes a new instance.
In order to transfer data between pages within an
application, you can use ApplicationState, SeesionState,
ViewState, or Cookie to save data in these objects, and
then share the data in different pages. In your case, you
can use SessionState to save data in page1. Then in page2
retrieve the data from SessionState.
To save data to SessionState:
Session("keyName") = obj;
To retrieve data from SessionState:
ObjectType obj = (ObjectType)Session("keyName");
HTH
Elton Wang
>-----Original Message-----
>Here is an example of my code and error location.
>The full code is much to large to post so here is an
abstract.
>
>Page1.aspx.cs
>
>public string Property1
>{
> get
> {
> return prop1;
> }
>}
>
>public string Property2
>{
> get
> {
> return prop2;
> }
>}
>
>page1.aspx
>
>populate a datagrid via data access and
><Columns>
> <asp:HyperLinkColumn DataNavigateUrlField="LocationID"
> DataNavigateUrlFormatString="page2.aspx?ID=
{0}"
>DataTextField="LocationName" HeaderText="Store">
> <HeaderStyle Font-Size="11px" Font-
Bold="True"></HeaderStyle>
> <ItemStyle Font-Size="11px" Wrap="False"
> HorizontalAlign="Left"CssClass="blueLink"
> VerticalAlign="Top"></ItemStyle>
> </asp:HyperLinkColumn>
>
>bla bla....
></Columns>
>
>page2.aspx.cs
>//define prop1 and prop2 as strings
>
>private void Page_Load
>(object sender, System.EventArgs e)
>{
> //create instance of source web form
> page1 p1;
>
> //get reference to current handler instance
> p1 = ( page1 )Context.Handler; <-------Here
is where the error
>ocurrs
> prop1 = p1.Property1;
> prop2 = p1.Property2;
>}
>
>I hope this is enough to work with.
>
>--
>Message posted via http://www.dotnetmonster.com
>.
>