Setting Style of Disabled Item on Web Form

K

Kubuli John

I have a LinkButton in an ASP.NET web form. Depending on the current
state of affairs, I either enable or disable the link button in by
code-behind class (e.g., disable the "Previous" button if you are
already at the first record). I have constructed a very nice style
for the button in my stylesheet, but the style is ignored when I
disable the button.

So, how do I control the display attributes of a disabled HTML widget?

Thanks...

John H.
 
C

Curt_C [MVP]

is this an ASP:xxx control or a HTML control?
Aspx = ... enabled=true/false.....
Html = ...disabled=true/false....

Show how you are doing it now
 
K

Kubuli John

It's an asp:linkbutton. In the HTML it looks like this:

<asp:linkbutton id="btnHome" runat="server" causesvalidation="False"
cssclass="toolbar">Home</asp:linkbutton>

The "toolbar" style is defined in a linked CSS:

..toolbar
{
font-family: Arial,Helvetica,sans-serif;
font-size: 8pt;
text-decoration: none;
text-align: center;
color: Blue;
background-color: Silver;
border-color: Gray;
border-style: ridge;
border-width: 2px;
width: 54px;
height: 19px;
}

In the codebehind page, I set it to disabled on a PostBack thusly:

btnHome.Enabled = false;

When I get the page back, all the stylesheet formatting is gone,
including the size, colors, and borders.

The .toolbar[disabled] syntax doesn't work.

Interesting observation - if I inline AT LEAST ONE of the style
elements, it uses it PLUS the stylesheet elements even for the
disabled state:

<asp:linkbutton id="btnHome" runat="server" causesvalidation="False"
cssclass="toolbar" borderwidth="2px">Home</asp:linkbutton>

This then keeps the border AND all of the stuff in the stylesheet -
only the actual text is grayed out. It's an OK workaround, but I
really like my styles to be all defined through the stylesheets.

John H.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top