Default. aspx has only one button and one text
Protected void button#click (Object sender, eventargs E)
{
Button1.postbackurl = "~ /Default2.aspx ";
}
Default2.aspx contains a text
If (previouspage! = NULL)
{
Textbox1.text = (previouspage. findcontrol ("textbox1") as textbox). text;
}
-----------------------------------------------------
Question: In default. aspx, click button1 twice to enter default2.aspx.
Solution:
Protected void button#click (Object sender, eventargs E)
{
Button1.postbackurl = "~ /Default2.aspx ";
}
The purpose of this Code is to set the URL address "~ /Default2.aspx "is assigned to the postbackurl attribute,
When you click it for the first time, it only serves as a value assignment,
During the second click, the button executes the postbackurl attribute mechanism to redirect the page to the page you want to jump.
You can directly assign the URL address to the postbackurl attribute at the front-end.
-
Method 1: HTML code
-
<asp:Button ID="Button1" runat="server" PostBackUrl="~/Default2.aspx" Text="baidu" />
-
Or,
-
Method 2: what is written in the background
-
C # code
-
protected void Button1_Click(object sender, EventArgs e){this.Button1.PostBackUrl ="~/Default2.aspxButton1_Click(this,e);}
-
Method 3: You can also put this sentence button1.postbackurl = "~ /Default2.aspx "; written in page_load