protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Label1.Text = mydb.RandomNum(4); } }
CommDB mydb = new CommDB(); //创建CommDB对象 protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) //在网页首发时执行 { Label1.Text = mydb.RandomNum(4); } else //回传时应保存密码 { TextBox2.Attributes.Add("value", TextBox2.Text); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Label1.Text = mydb.RandomNum(4); } else { TextBox2.Attributes.Add("value", TextBox2.Text);//回发时保持密码 } }
protected void Button3_Click(object sender, EventArgs e) { Label1.Text = mydb.RandomNum(4); }