I'm trying to build a website. And I'm wondering what the best way to hold the users information would be prior to them going to the register page. So for example:
Front page
What kind of house do you live in? ...Textbox1
How many rooms does it have?....Textbox2
Submit button<click>
Next Page
progress bar searching for records..
Next page
Your house & rooms were not found, however we encourage you to <hyperlink>register<hyperlink> click
Register Page
asp createuserwizard etc etc....
Soooooo....Do I use the users IP address or what unique way is there to hold their start information from the textboxes they have already entered so that I can add them to a new database table that I make in the database? Or do I put all of their information
as a temp table? Or does it have something to do with cookies?
If you want to move data from one page to another , then There are mutliple ways you can acheive this functionality
1) Using Form
When the source page uses the HTTP POST action to navigate to the target page, you can retrieve posted values from the Form collection
in the target page.
This basically involves two steps
In the source page, include a form element that contains HTML elements (such as input or textarea) or ASP.NET server controls (such as TextBox orDropDownList controls)
that post values when the form is submitted.
In the target page, read the Form collection, which returns a dictionary of name/value pairs, one pair for each posted value.
Please try with the below implementaion
Your PageA.aspx
<formid="form2"runat="server"><asp:TextBoxID="EmployeeName"runat="server"></asp:TextBox><!-- Add Your Other controls here --><asp:ButtonID="btnSubmit"runat="server"Text="Submit"PostBackUrl="YourPageB.aspx"/></form>
You can access the posted values using Request.Form in your PageB.Aspx
Your PageB.Aspx
//Grab the value passed from YourPageA.aspxStringPassedvalue=Request.Form["EmployeeName"];
2) Using Session
An Easy solution is to use session and it will be like this
Your PageA.aspx
//Set the value of Textbox to sessionSession["Data"]=Textbox1.Text;//Perform your RedirectResponse.Redirect("YourPageB.aspx");
YourPageB.aspx(Receiver Page)
You can read values from session like given below
if(!String.IsNullOrEmpty(Session["Data"].ToString())){//Read values from sessionstring valueA =Session["Data"].ToString();}
3) Another suggestion is to use QueryString
Please see the sample implemenation
Your PageA.aspx
You can pass value to pageB like given below
protectedvoid btnRedirect_Click(object sender,EventArgs e){//Pass the value from Textbox as Query stringResponse.Redirect("YourPageB.aspx?PassingValue="+Server.UrlEncode(Textbox1.Text));}
YourPageB.aspx(Receiver Page)
You can read the value passed through query string like given below
//Read the values from Query stringstring value =Request.QueryString["PassingValue"].ToString();
Member
2 Points
20 Posts
data store for moving from page to page
Dec 18, 2016 04:13 AM|geomeo123|LINK
Hello,
I'm trying to build a website. And I'm wondering what the best way to hold the users information would be prior to them going to the register page. So for example:
Front page
What kind of house do you live in? ...Textbox1
How many rooms does it have?....Textbox2
Submit button<click>
Next Page
progress bar searching for records..
Next page
Your house & rooms were not found, however we encourage you to <hyperlink>register<hyperlink> click
Register Page
asp createuserwizard etc etc....
Soooooo....Do I use the users IP address or what unique way is there to hold their start information from the textboxes they have already entered so that I can add them to a new database table that I make in the database? Or do I put all of their information as a temp table? Or does it have something to do with cookies?
Thanks
George
All-Star
50831 Points
9895 Posts
Re: data store for moving from page to page
Dec 18, 2016 07:15 AM|A2H|LINK
If you want to move data from one page to another , then There are mutliple ways you can acheive this functionality
1) Using Form
When the source page uses the HTTP POST action to navigate to the target page, you can retrieve posted values from the Form collection in the target page.
This basically involves two steps
In the source page, include a form element that contains HTML elements (such as input or textarea) or ASP.NET server controls (such as TextBox orDropDownList controls) that post values when the form is submitted.
In the target page, read the Form collection, which returns a dictionary of name/value pairs, one pair for each posted value.
Please try with the below implementaion
Your PageA.aspx
You can access the posted values using Request.Form in your PageB.Aspx
Your PageB.Aspx
2) Using Session
An Easy solution is to use session and it will be like this
Your PageA.aspx
YourPageB.aspx(Receiver Page)
You can read values from session like given below
3) Another suggestion is to use QueryString
Please see the sample implemenation
Your PageA.aspx
You can pass value to pageB like given below
YourPageB.aspx(Receiver Page)
You can read the value passed through query string like given below
You can get more details in the below link
Aje
My Blog | Dotnet Funda