Thursday, March 29, 2012

Please change my readonly (Enabled=false) checkbox style as it is difficult to read.

Hi,

This has been bugging me for a while so any help is appreciated.

How do I change the style of a readonly checkbox? (i.e. Enabled = False) - it's very difficult to read

I am displaying a set of checkbox based on some database query which works fine - however the faded checkbox and tick are not easy to see. I don't want to use skin files/themes if I can help it.

The only option I can think of is to display the database results (1 or 0) as images (1 for empty checkbox and 1 for full checkbox) but it seems a bit over the top.

I may be missing something simple but I have tried various checkbox parameter settings to no avail.

Many thanks

MrCadburysParrot

I had the same concern and I wound up using images. Over the top? That's all I could get working...

 <asp:TemplateField HeaderText="Freeze Definition" SortExpression="FreezeDefn"> <ItemTemplate> <asp:Image ImageUrl="../../images/CheckBoxYes.gif" ID="imgFreezeDefnTrue" runat="server" Visible='<%# Convert.ToBoolean(Eval("FreezeDefn"))%>'> </asp:Image> <asp:Image ImageUrl="../../images/CheckBoxNo.gif" ID="imgFreezeDefnFalse" runat="server" Visible='<%# !Convert.ToBoolean(Eval("FreezeDefn"))%>'> </asp:Image> </ItemTemplate> <EditItemTemplate> <asp:CheckBox ID="cbxFreezeDefn" runat="server" checked='<%# Convert.ToBoolean(Eval("FreezeDefn"))%>'> </asp:CheckBox> </EditItemTemplate> <FooterTemplate> <asp:CheckBox ID="cbxNewFreezeDefn" runat="server" > </asp:CheckBox> </FooterTemplate> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" Width="120px" Wrap="True" /> <FooterStyle HorizontalAlign="Center" /> </asp:TemplateField>

Hi,

Thanks for the response. It does seem the only way to do it. I ended up using

<asp:ImageID="chkD7Adjusted"runat="server"ImageUrl='<%# DisplayCheckGraphic(Eval("Interlocks")) %>'/>

The function DisplayCheckGraphic then returns a string value (depending on the Interlocks value) denoting the appropriate Image URL.

I'll leave the post running for a few days to see if anyone has a direct answer to the checkbox issue - if not I will allocate your response as the answer as it was same as the method that I am currently using.

Thanks

MrCadburysParrot


You can do many things such as setting style etc around it.

one way is to

Get the checked event in javascript and then

e.ParentNode.style.border =(e.checked ? 'outset' :' ' );

or for a simple readonly setting its style to outset, so that it becomes raised.


Yeah, you could stick it on the stylesheet too. That would be much neater. I'm not a designer though so I don't do much with styles beyong making something readable. I really would like to put some time into sexy-ing up my pages but I'm too busy developing functionality and working on ETL and such. So is everyone else on the team - the guy with the design skills is busy writing code generators.

Plus I can't stand CSS language. Why is it different than the syntax used for styles in ASP? The don't even have the same attributes... grr. Does silverlight encapsulate this kind of stuff by any chance? Is there something on the horizon that will give us a styling GUI? Thanks.


Charles Asbornsen:

Yeah, you could stick it on the stylesheet too. That would be much neater. I'm not a designer though so I don't do much with styles beyong making something readable. I really would like to put some time into sexy-ing up my pages but I'm too busy developing functionality and working on ETL and such. So is everyone else on the team - the guy with the design skills is busy writing code generators.

Plus I can't stand CSS language. Why is it different than the syntax used for styles in ASP? The don't even have the same attributes... grr. Does silverlight encapsulate this kind of stuff by any chance? Is there something on the horizon that will give us a styling GUI? Thanks.

Charles

CSS is a standard and rather a markup where as Asp.net is a framework and CSS existed way before Asp.net and imagine sugar and water cannot be same thing, however sugar provides sweetness to water. Silverlight is imagine a plugin like flash and CSS will still be at play. Yes there are skins but they also work with cSS.

Best regards


A poetic allusion for a buggering annoyance. Big Smile I appreciate the "objectiness" of CSS (kind of like truthiness), and I'd like to go through all my code and CSS the whole works, but that has to wait until all our deliverables are, um, delivered. I could really use some CSS training. I just wish I could go to something like powerpoint, draw my styled control in that, and then say "hey you, this is your style when selected, and this is your style when mouseover" and so forth without 28 lines of code...

0 comments:

Post a Comment