Q: move between pages

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
What is the best way to move from aspx page to aspx page by passing
variables. I was using session variables with Response.Redirectin both ways,
it may not be the right way. Users click a button in the current page and I
need pass a variable to use in the second page and when user click close I
need to jump back to first page. How can I do this? Can you give me exaple
please?
Thanks,
Jim.
 
Thanks for the reply. all these htlm confuses me. can I handle it code
behind? can you give me a site that has query string example.
 
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79
 
Hello,
I have;
string strName = this.Context.Items["name"].ToString();
in page_load in WebForm2.aspx. It works fine when loading, I need to close
this page and return back to first page so I have a close button with
Response.Redirect("MyPage.aspx");
When I click I get “Object reference not set to an instance of an object.â€
at tle line I mentioned above. What should I do?
Thanks,
Jim.
 
Try ignoring the error or playing with the 2nd (endResponse) parameter as
documented here:
http://msdn.microsoft.com/library/d...fsystemwebhttpresponseclassredirecttopic2.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


JIM.H. said:
Hello,
I have;
string strName = this.Context.Items["name"].ToString();
in page_load in WebForm2.aspx. It works fine when loading, I need to close
this page and return back to first page so I have a close button with
Response.Redirect("MyPage.aspx");
When I click I get "Object reference not set to an instance of an object."
at tle line I mentioned above. What should I do?
Thanks,
Jim.


Steve C. Orr said:
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page,
etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79
 
Back
Top