Disabling all the Page Control through jQuery

后端 未结 4 792
有刺的猬
有刺的猬 2021-01-26 16:29

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:

4条回答
  •  臣服心动
    2021-01-26 16:51

    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.

提交回复
热议问题