开发者

disabled attribute not working

开发者 https://www.devze.com 2023-01-14 16:59 出处:网络
For some reason none of these DIVs render disabled.Oddly enough, when I set Enabled=\"False\" on the .NET Panel, then it renders the Panel as a DIV with disabled=\"disabled\", which works great.

For some reason none of these DIVs render disabled. Oddly enough, when I set Enabled="False" on the .NET Panel, then it renders the Panel as a DIV with disabled="disabled", which works great.

Here's my doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<div id="Div1" disabled="disabled">
    <input type="text" value="blah" />        
</div>

<div id="disableMe" disabled="disabled">
    <input type="text" value="blah" />
    <asp:Panel runat="server">
        <asp:RadioButtonList runat="server">
            <asp:ListItem Text="Item1" Selected="True" />
         开发者_JAVA技巧   <asp:ListItem Text="Item2" />
        </asp:RadioButtonList>

        <asp:TextBox runat="server" Text="Hello World" />
    </asp:Panel>
</div>


Disabled is not an attribute for a DIV, but an attribute for every form element (like INPUT, SELECT, TEXTAREA).

Just add the disabled attribute to ever form element within the DIV.


I guess the disabled="disabled" gets parsed server side and applies that status to children fields (runat="server"), because in html there's no disabled="disabled" for <div> elements.


You basically want to use CSS display: none here.

<div style="display: none;">

A <div> is a simple HTML element and get printed to HTTP response as-is, it's not some server side component which generates some HTML (like as those other ASP.NET components are doing).

0

精彩评论

暂无评论...
验证码 换一张
取 消