I am working on asp.net and c#.
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...
I need a Simple and short method to disabled all the Controls when i call this jQuery method on some condition.
Any Help?
Thanks in Advance...
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.
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');
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.
Can you put all that controls in the Panel? you can disable panel, and all controls in it will be disabled, in JS it's as easy as disabling div tag, in BE it's easier.
$('input,select').attr('readonly', 'readonly');
You can use a below code for this purpose:
js
on click:
$('body').append('<div class="noclick" />');
once done:
$(".noclick").remove();
css:
.noclick {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 9999; /* or maybe higher */
background-color: transparent;
}