C# 在按钮单击功能运行时禁用按钮或光标等待图标
我有一个按钮点击功能,可以加载和运行SSIS包C# 在按钮单击功能运行时禁用按钮或光标等待图标,c#,asp.net,ssis,C#,Asp.net,Ssis,我有一个按钮点击功能,可以加载和运行SSIS包 <asp:Button ID="btnDoSomething" runat="server" Text="TEST run SSIS" OnClientClick="return confirm('TEST-TEST-TEST')" OnClick="btnDoSomething_Click" /> 更新:感谢您的帮助 因为我需要确认,我添加了一个简单的脚本 function getConfirm() {
<asp:Button ID="btnDoSomething" runat="server" Text="TEST run SSIS"
OnClientClick="return confirm('TEST-TEST-TEST')"
OnClick="btnDoSomething_Click" />
更新:感谢您的帮助强>
因为我需要确认,我添加了一个简单的脚本
function getConfirm() {
if (confirm("Are you sure you want to generate letters for all RELEASED campaigns?")) {
showOverlay();
return true;
}
else return false;
}
并将onClientClick更改为调用它
OnClientClick=“return getConfirm();”
对于IE,我还添加了
filter: alpha(opacity = 40);
以使其正确显示不透明度
我喜欢这套衣服。。谢谢!!:) 选项1:禁用按钮 定义一个javascript函数,如下所示。您必须返回
true
,否则服务器事件将不会触发:
function disabledMe(btn) {
btn.disabled = "disabled";
return true;
}
然后,像这样使用它:
<asp:Button ID="btnDoSomething" runat="server" Text="TEST run SSIS"
OnClientClick="disabledMe(this);"
OnClick="btnDoSomething_Click" />
在服务器事件结束时,注册脚本以调用函数隐藏覆盖:
<div id="overlay" class="overlay"></div>
protected void btnDoAnythingElse_Click(object sender, EventArgs e)
{
Thread.Sleep(2000); // simulates a long running process
ClientScript.RegisterStartupScript(this.GetType(), "hideOverlay", "hideOverlay();", true);
}
OnClientClick=“this.disabled=true”
hmmm。。嗯,我真的很喜欢你关于解决方案2的想法。。我仍然非常需要confirm onClientClick这一块——有什么办法可以同时运行这两个功能吗?真是妙极了!!现在完全是金色的。我创建了一个简单的脚本来执行询问、隐藏和返回操作——谢谢!!!不,真奇怪。浏览器控制台是否显示任何错误?
<style type="text/css">
.overlay {
background-color: #000;
cursor: wait;
display: none;
height: 100%;
left: 0;
opacity: 0.4;
position: fixed;
top: 0;
width: 100%;
z-index: 9999998;
}
</style>
<script>
function showOverlay() {
document.getElementById("overlay").style.display = "block";
}
function hideOverlay() {
document.getElementById("overlay").style.display = "none";
}
</script>
<asp:Button ID="btnDoAnythingElse" runat="server"
Text="TEST run SSIS" OnClientClick="showOverlay();"
OnClick="btnDoAnythingElse_Click" />
protected void btnDoAnythingElse_Click(object sender, EventArgs e)
{
Thread.Sleep(2000); // simulates a long running process
ClientScript.RegisterStartupScript(this.GetType(), "hideOverlay", "hideOverlay();", true);
}