ASP.NET - 单击时禁用字段 [英] ASP.NET - Disable fields on click

查看:109
本文介绍了ASP.NET - 单击时禁用字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有多个按钮的页面。

当我点击一个按钮时,它会触发一个SQL程序并运行它。

直到该过程结束我想要所有要禁用的页面中的其他按钮。

我使用下面的代码,但它只禁用我点击的按钮,而不是剩下的按钮。



请帮忙!



<前lang =c#> 受保护 void Page_Load( object sender,EventArgs e)
{
this .DisableButtonOnPostBack( this .btnGo, 等待...);
}

public void DisableButtonOnPostBack(按钮按钮, string text)
{
button.Attributes [ onclick] =
string .Format( this.value ='{0}'; this.disabled = true; {1};,text,
button.Page.ClientScript.GetPostBackEventReference(button, null ));
}
}





删除喊叫[/编辑]

解决方案

除了解决方案1,这里还有另一个链接可以帮助你实现javascript。

在AJAX回发期间ASP.Net禁用按钮 [ ^ ]

- 另一种方法,如果你想申请 -

你可以在处理时禁用鼠标点击,这样你就不会必须禁用所有按钮。请查看链接以获取更多信息:

使用Javascript处理时禁用鼠标点击 [ ^ ]



祝你好运,

OI


在ASP.NET网页中使用控件集合 [ ^ ],您可以使用每个页面上的Controls Collection来禁用按钮该页面。


I have a page with multiple buttons.
When i click on a button, it triggers a SQL procedure and runs it.
Till that process finishes i want all the other buttons in the page to be disabled.
I use the below code but it disables only the button which i clicked and not the remaining buttons.

Please help!

protected void Page_Load(object sender, EventArgs e)
		{
			this.DisableButtonOnPostBack(this.btnGo, "Wait...");
		}

		public void DisableButtonOnPostBack(Button button, string text)
		{
	button.Attributes["onclick"] =
	string.Format("this.value = '{0}';this.disabled = true;{1};",text,
                        button.Page.ClientScript.GetPostBackEventReference(button, null));
		}
	}



[Edit]Removed shouting[/Edit]

解决方案

In addition to solution 1 here is another link that can help you achieve with javascript.
ASP.Net Disable Buttons during AJAX Postback[^]
- Another approach if you want to apply -
You can disable mouse click while processing so you do not have to disable all the buttons. Please check the link for more info:
Disabling Mouse clicks while processing using Javascript[^]

Good luck,
OI


As demonstrated at Using the Controls Collection in an ASP.NET Web Page[^], you can use the Controls Collection on each page to disable buttons on that page.


这篇关于ASP.NET - 单击时禁用字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆