通过jQuery的禁用所有的页面控件有的、控件、页面、jQuery

2023-09-04 01:27:00 作者:还没燃尽的烟

我的工作asp.net和C#。

I am working on asp.net and c#.

我使用大量的ASP和HTML控件的页面上,并在某些情况下,所有的控制被禁用。 一些使用的控制是:

I am using lots of ASP and HTML controls on the page and in some cases all the controls gets disabled. Some of the used Controls are:

RadioButton
RadioButtonList
CheckBox
CheckBoxList
TextBox
DropDownList
Button
etc...

我需要一个简单的和短期的方法来禁用所有的控件时,我呼吁一定条件下这个jQuery的方法。 任何帮助吗?

I need a Simple and short method to disabled all the Controls when i call this jQuery method on some condition. Any Help?

在此先感谢...

推荐答案

严格来说,你不能在所有使用jQuery禁用任何服务器控件,该服务器控件,而呈现页面时在服务器上,当页面到达时只存在在浏览器只呈现code留在控制。

Strictly speaking you can't disable any server controls at all using jQuery, the server controls only exist while the page is rendered on the server, when the page arrives in the browser only the rendered code is left of the controls.

您必须找出什么HTML元素从控制渲染和禁用这些元素。例如:

You have to find out what html elements are rendered from the controls and disable those elements. For example:

$('input[type=submit], input[type=checkbox], select, input[type=text], textarea').attr('disabled','disabled');

请注意,一个控件可以呈现为依赖于它的属性不同的HTML元素。与文本模式= SINGLELINE一个文本框将呈现为输入类型=文本,同时与文本模式=多行文本框呈现为一个文本区域。

Note that a control can be rendered as different html elements depending on it's attributes. A TextBox with TextMode=SingleLine is rendered as an input type="text", while a TextBox with TextMode=MultiLine is rendered as a textarea.

 
精彩推荐
图片推荐