Last post Dec 18, 2016 07:15 AM by A2H
Dec 18, 2016 04:13 AM|geomeo123|LINK
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:
What kind of house do you live in? ...Textbox1
How many rooms does it have?....Textbox2
progress bar searching for records..
Your house & rooms were not found, however we encourage you to <hyperlink>register<hyperlink> click
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?
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
<form id="form2" runat="server">
<asp:TextBox ID="EmployeeName" runat="server"></asp:TextBox>
<!-- Add Your Other controls here -->
<asp:Button ID="btnSubmit" runat="server" Text="Submit" PostBackUrl="YourPageB.aspx" />
You can access the posted values using Request.Form in your PageB.Aspx
//Grab the value passed from YourPageA.aspx
String Passedvalue = Request.Form["EmployeeName"];
2) Using Session
An Easy solution is to use session and it will be like this
//Set the value of Textbox to session
Session["Data"] = Textbox1.Text;
//Perform your Redirect
You can read values from session like given below
//Read values from session
string valueA = Session["Data"].ToString();
3) Another suggestion is to use QueryString
Please see the sample implemenation
You can pass value to pageB like given below
protected void btnRedirect_Click(object sender, EventArgs e)
//Pass the value from Textbox as Query string
Response.Redirect("YourPageB.aspx?PassingValue=" + Server.UrlEncode(Textbox1.Text));
You can read the value passed through query string like given below
//Read the values from Query string
string value = Request.QueryString["PassingValue"].ToString();
You can get more details in the below link