62,243
社区成员




public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button button1 = new Button();
button1.Text = "Click";
button1.ID = "button1";
TextBox textBox1 = new TextBox();
textBox1.Text = "Good Morning.";
textBox1.ID = "textBox1";
if (IsPostBack)
{
textBox1.Text = "Good Afternoon.";
}
Form.Controls.Add(button1);
Form.Controls.Add(textBox1);
}
}
if (!IsPostBack)
{
Button button1 = new Button();
button1.Text = "Click";
button1.ID = "button1";
TextBox textBox1 = new TextBox();
textBox1.Text = "Good Morning.";
textBox1.ID = "textBox1";
Form.Controls.Add(button1);
Form.Controls.Add(textBox1);
}
else
{
Button button1 = new Button();
button1.Text = "Click";
button1.ID = "button2";
TextBox textBox1 = new TextBox();
textBox1.Text = "Good Afternoon.";
textBox1.ID = "textBox2"; // 名字得换一下,如果不换由于IE缓存问题将不更新TextBox内容
Form.Controls.Add(button1);
Form.Controls.Add(textBox1);
}
static Button button1;
static TextBox textBox1;
protected void Page_Load(object sender, EventArgs e)
{
Response.Expires = -1;
if (!IsPostBack)
{
button1 = new Button();
button1.Text = "Click";
button1.ID = "button1";
textBox1 = new TextBox();
textBox1.Text = "Good Morning.";
textBox1.ID = "textBox1";
}
else
{
textBox1.Text = "Good Afternoon.";
textBox1.ID = "textBox2"; // 名字得换一下,如果不换由于IE缓存问题将不更新TextBox内容
}
Form.Controls.Add(button1);
Form.Controls.Add(textBox1);
}
public partial class _Default : System.Web.UI.Page
{
private Button button1;
private TextBox textBox1;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
button1 = new Button();
button1.Text = "Click";
textBox1 = new TextBox();
textBox1.Text = "Good Afternoon.";
}
else
{
button1 = new Button();
button1.Text = "Click";
textBox1 = new TextBox();
textBox1.Text = "Good Morning.";
}
Form.Controls.Add(button1);
Form.Controls.Add(textBox1);
}
}
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox1.Text = "Good Morning.";
if (IsPostBack)
{
this.TextBox1.Text = "Good Afternoon.";
}
Form.Controls.Add(this.Button1);
Form.Controls.Add(this.TextBox1);
}
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Button button1 = new Button();
button1.Text = "Click";
button1.ID = "button1";
TextBox textBox1 = new TextBox();
textBox1.Text = "Good Morning.";
textBox1.ID = "textBox1";
Form.Controls.Add(button1);
Form.Controls.Add(textBox1);
}
else
{
textBox1.Text = "Good Afternoon.";
}
}
}