ASP.net Bengali tutorial part-2 || Send page values from one page to another page in ASP.net
There are many ways you can transfer your one page values to another page either using (1) Cookies or (2) Using QueryString. In this tutori...
https://things-for-students.blogspot.com/2013/06/aspnet-bengali-tutorial-part-2-send.html
There
are many ways you can transfer your one page values to another page either
using (1) Cookies or (2) Using QueryString. In this tutorial I will discuss
both of them. In my tutorial I have used visual studio 2005 and .net 2.0. You
may use higher version of visual studio, but the procedure and code will remain
same. This process will reduce the use of database but it also reduces data
security. One have fair knowledge in web address can easily identify those
data.
Send Page value using QueryString
This procedure happens on client side but it is slightly different from cookies. Here no data will be stored on client’s machine instead of that page value will be transferred from one page to another.
Step 1:
In this tutorial I have used two pages (1) Default.aspx (2) Default2.aspx
Now in Default.aspx page take two textboxes and two labels and one button. The button will function like, when we click the button TextBox1 and TextBox2 values will be transferred to Default2.aspx page.
Now write the following code on Default.aspx.cs page inside button1_click method.
Now on Default2.aspx page take two labels and one TextBox as shown in below picture.
After that write the following code on Deeeeefault2.aspx.cs inside Page_Load method.
In this tutorial I have used two pages (1) Default.aspx (2) Default2.aspx
Now in Default.aspx page take two textboxes and two labels and one button. The button will function like, when we click the button TextBox1 and TextBox2 values will be transferred to Default2.aspx page.
protected void Button1_Click(object sender, EventArgs e)
{
string url;
url = "Default2.aspx?name=" +
TextBox1.Text + "&email=" +
TextBox2.Text;
Response.Redirect(url);
}
Step 2:{
string url;
url = "Default2.aspx?name=" +
TextBox1.Text + "&email=" +
TextBox2.Text;
Response.Redirect(url);
}
Now on Default2.aspx page take two labels and one TextBox as shown in below picture.
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.QueryString["name"];
Label2.Text = Request.QueryString["email"];
TextBox1.Text = Label2.Text;
}
If you face any difficulty in any phase feel free to comment. Very soon I will post about how cookies store page values and how to access that stored data.{
Label1.Text = Request.QueryString["name"];
Label2.Text = Request.QueryString["email"];
TextBox1.Text = Label2.Text;
}