There are several ways to achieve this. I can briefly explain to you the 4 types that we use in our daily programming life cycle.
Please proceed to the following points.
1 Request string.
FirstForm.aspx.cs
Response.Redirect("SecondForm.aspx?Parameter=" + TextBox1.Text);
SecondForm.aspx.cs
TextBox1.Text = Request. QueryString["Parameter"].ToString();
This is the most reliable way when you pass an integer value type or other short parameters. Make enough progress in this method, if you use any special characters in the value when passing it along the query line, you must encode the value before moving to the next page. So, our code fragment will be something like this:
FirstForm.aspx.cs
Response.Redirect("SecondForm.aspx?Parameter=" + Server.UrlEncode(TextBox1.Text));
SecondForm.aspx.cs
TextBox1.Text = Server.UrlDecode(Request.QueryString["Parameter"].ToString());
2. Passing a value through a context object
Passing a value through a context object is another commonly used method.
FirstForm.aspx.cs
TextBox1.Text = this.Context.Items["Parameter"].ToString();
SecondForm.aspx.cs
this.Context.Items["Parameter"] = TextBox1.Text;
Server.Transfer("SecondForm.aspx", true);
, , Server.Transfer Response.Redirect. Session . Session, Session .
3. PostBack
. :
FirstForm.aspx.cs
private void Page_Load(object sender, System.EventArgs e)
{
buttonSubmit.Attributes.Add("onclick", "return PostPage();");
}
javascript .
SecondForm.aspx.cs
function PostPage()
{
document.Form1.action = "SecondForm.aspx";
document.Form1.method = "POST";
document.Form1.submit();
}
TextBox1.Text = Request.Form["TextBox1"].ToString();
, . , . EnableViewStateMac=false
4. PostBackURL
ASP.NET 2.0 Microsoft , PostBackURL . - , .
FirstForm.aspx.cs
<asp:Button id=buttonPassValue style="Z-INDEX: 102″ runat="server" Text="Button" PostBackUrl="~/SecondForm.aspx"></asp:Button>
SecondForm.aspx.cs
TextBox1.Text = Request.Form["TextBox1"].ToString();
PostBackUrl , , , . , Request.
PreviousPage Request.
SecondForm.aspx
TextBox textBoxTemp = (TextBox) PreviousPage.FindControl("TextBox1″);
TextBox1.Text = textBoxTemp.Text;
, .
: " - ASP.NET"