Wednesday, March 21, 2012

passing variables question

Ok, sorry if this is dumb ?, but I'm extremely new to ASP.net. I've used
PHP and am now trying to figure out the best way (or any way) to do this in
ASP.net:
I have a page where the user enters data and clicks a submit button which
redirects to another page. This 2nd page can retrieve all of the POST
variables submitted from the previous page. How is this done in ASP.net?
Thanks!The ASP.NET model is for the first page to handle its own data submission.
It should deal with the data, and then redirect to the next page. That page
then handles all its own data.
If you did want to do what you are describing, you would either need to set
the form to post to the second page to begin with, or you would need to do a
Server.Transfer to the second page.
"melinda" <melinda@.discussions.microsoft.com> wrote in message
news:5033F7C5-5EB7-446E-B145-2B3443C58ECF@.microsoft.com...
> Ok, sorry if this is dumb ?, but I'm extremely new to ASP.net. I've used
> PHP and am now trying to figure out the best way (or any way) to do this
> in
> ASP.net:
> I have a page where the user enters data and clicks a submit button which
> redirects to another page. This 2nd page can retrieve all of the POST
> variables submitted from the previous page. How is this done in ASP.net?
> Thanks!
You can save the values to a a session and redirect the page to the
second page and then read from the session.
Also, this might help:
http://authors.aspalliance.com/kenc/passval.aspx
Shahid
"melinda" <melinda@.discussions.microsoft.com> wrote in message
news:5033F7C5-5EB7-446E-B145-2B3443C58ECF@.microsoft.com...
> Ok, sorry if this is dumb ?, but I'm extremely new to ASP.net. I've used
> PHP and am now trying to figure out the best way (or any way) to do this
> in
> ASP.net:
> I have a page where the user enters data and clicks a submit button which
> redirects to another page. This 2nd page can retrieve all of the POST
> variables submitted from the previous page. How is this done in ASP.net?
> Thanks!
ASP.NET forms by default submit to self.
I generally put my code in the button click server event. Then I redirect
to the next page if all goes well.
John
There are different technique to transfer data from one page to another. The
simple and easy way is to use Session Variable. You can also use QueryString
.
For Session variable, You can save the values to a session and redirect the
destination page and then read the date from the session.
let there are two pages WebForm1.aspx and WebForm2.aspx. on the WebForm1 you
have 2 string variables and u want to access these two variables on 2nd page
U have to do on the Webform1.aspx:
string name = "Irfan";
string age = 30;
Session["anySessionVariableName1"] = name;
Session["anySessionVariableName2"] = age;
Response.Redirect("WebForm2.aspx");
on the WebForm2.aspx, u have to do for retrieving the name and age:
string nm = Session["anySessionVariableName1"].ToString();
string ag = Session["anySessionVariableName2"].ToString();
"melinda" wrote:

> Ok, sorry if this is dumb ?, but I'm extremely new to ASP.net. I've used
> PHP and am now trying to figure out the best way (or any way) to do this i
n
> ASP.net:
> I have a page where the user enters data and clicks a submit button which
> redirects to another page. This 2nd page can retrieve all of the POST
> variables submitted from the previous page. How is this done in ASP.net?
> Thanks!

0 comments:

Post a Comment