| 实例讲解asp.net防止按钮多次提交问题 |
| 来源:
发布时间:2008-07-22 发布人:
浏览:
人次
字体:
[大
中
小]
|
|
服务器端代码,故意让其延时等待3秒后再输入,以模拟数据库操作等慢速动作。 1public partial class Default2 : System.Web.UI.Page 2{ 3 static public int count = 0; 4 protected void Page_Load(object sender, EventArgs e) 5 { 6 if (!IsPostBack) 7 { 8 Button2.Attributes.Add("onclick", "return DisableButton();"); 9 } 10 } 11 12 protected void Button2_Click(object sender, EventArgs e) 13 { 14 if (TextBox1.Text != string.Empty) 15 { 16 System.Threading.Thread.Sleep(3000); 17 count++; 18 ListBox1.Items.Add(new ListItem("Hello "+TextBox1.Text + " 这是你第" + count.ToString() + "次点击 " + DateTime.Now.ToString())); 19 TextBox1.Text = ""; 20 } 21 } 22}
共2页: 上一页 [1] 2 下一页
| |
| |
|
|
|
|
| §最新评论:(评论内容只代表网友观点,与本站立场无关!) | |
|
|
|
|
| 注意:请勿在本站发布政治话题、色情及违反法律的内容。 |
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。 |