473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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!
Nov 19 '05 #1
5 2061
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" <me*****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.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!

Nov 19 '05 #2
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

Nov 19 '05 #3
"melinda" <me*****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.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


Nov 19 '05 #4
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 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!

Nov 19 '05 #5
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 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!

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Amr Mostafa | last post by:
Hello :) I'm trying to write a script that deals with a web service. I'm using NuSoap class. my question is : Can I pass some variables By Reference to the web service and get the result back...
4
by: Jason Us | last post by:
Does anyone have experience with passing variables from an ASP page to a JSP page. The way it currently works in passing the SSN in the URL. This cannot be good. I thought that storing a...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
1
by: Russell | last post by:
Hi there, I'm currently creating a .NET Web Application and I have a question about passing values from one screen to another. I previously used Session variables in the code to store these...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
7
by: The Doctor | last post by:
A rather elementary question, In VB5, how can I pass a variable from one form to another?
7
by: andy | last post by:
A question about about passing a class by reference: Say you have a class called car, and within that you have two objects called car01 and car02. Within the class I have an int variable...
1
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call...
2
by: peterWolf | last post by:
Hi there, i have a quick question about passing SQL statements to a server. I am using Borland C++ v6 and using MS SQL 2005 express edition. I am new to the world of SQL so would like either a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.