按钮ID为:btnSubmit
为实现rt功能,只需要添加两句代码即可。
1. 在.aspx页面第一行<%@ Page %>中添加:
EnableEventValidation="false"
2. 在服务端代码的Page_Load方法中添加如下代码:
//使按钮不可用并回调服务端事件
this.btnSubmit.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnSubmit, "Click") + ";this.disabled=true; this.value='提交中...';");
提供网上其他人写的一个简单示例:
//使按钮不可用并回调服务端事件
protected void Page_Load(object sender, EventArgs e)
{
this.btnOK.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnOK, "Click") + ";this.disabled=true; this.value='提交中...';");
}
//按钮处理方法
protected void btnOK_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);
ClientScript.RegisterStartupScript(GetType(), "btnCommit", "alert('提交成功!!!');", true);
}
本文介绍如何在ASP.NET页面中实现rt功能,包括禁用按钮、回调服务端事件以及处理按钮点击事件的基本步骤。通过示例代码演示了如何在页面加载时和按钮点击事件中进行操作。
1万+

被折叠的 条评论
为什么被折叠?



