Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Disabled, but no Grey

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
I'm sure I've done this before somehow, but for some reason it doesn't want to jive this time:

I have a checkbox. The checkbox needs to be disabled for a certain state of the page, but I don't want it to LOOK disabled.

I was sure that I've set the forecolor property of the checkbox to black, and thats solved it, but now it just ignores it! I also remember using a panel as the trick (setting the panel to be disabled, but the controls within would look the same), but that doesn't work anymore either (or it never did, and my memory is shot).

Any ideas on how I can accomplish this?

Thanks

Jack
 
how about using an image of the checkbox and enable and disable the visible property of the image and the checkbox following your state selection.
In anycase why would you do that? I can just see how many phone calls you are going to receive of people saying:

"the checkbox is broken or stuck"

hth
 
Alcar:

We're creating a job management system for a roofing company. On their client screen, we have a panel that has all the fields for them to enter the information. One of them is a checkbox for Active/Un-Active.

They need to be able to view the information, but also edit the information if they have permission to do so. That means that we need to stop them from monkeying around with teh controls. BUT, we can't just set the enabled property because, since they want to view the items, they DON'T WANT TO SEE THE GREYED OUT CONTROLS. Thus, we have a whole bunch of Read-Only=True textboxes, and a difficult, greying-out checkbox that needs to be dealt with.

Short term (and what I hope they like) is actually a colored button for red = active, black = not active. It just means more code behind the scenes.

Thanks for the post,

Jack
 
You can use the ever-popular:

onFocus="this.blur();"

to disable a control on a page w/out actually "disabling" it. I suppose you'd need to apply the attribute to the checkbox based on what view you're currently in, but that little bit of javascript works quite nicely.

:)
paul
penny1.gif
penny1.gif
 
Heh, the checkbox didn't like the this.blur() script being added to it. Silly checkbox.

We did figure a workaround:

We create a viewstate variable to hold whether the page is in read only mode or not. Then, we just evaluate it and if its true, Checkbox1.Checked = Not Checkbox1.Checked

It requires a postback, but it does the job at least.
(and hopefully they won't be clicking on it too much).

Just a note about Checkboxes too:
The help will tell you that the html checkbox has a ReadOnly property. This property, when assigned, is supposed to maintain the value of the checkbox, even though the user can check the control (yeah, I didn't get it either). Anyway, asp.net checkboxes don't support this property, and even in the html examples we tried, we couldn't get it to work.

Thanks guys,

Jack
 
Good to hear you have found a workaround. I hate to be stuck. Good Luck with the rest of the project!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top