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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick events in asp.net with vb.net for a web form

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I have various checkboxes that I want to disable or enabled based on a different checkbox being checked or unchecked. Say checkbox1 if chekced will disable checkbox2.

so :

if checkbox1.checked = true then
checkbox2.enabled = false
end if

I would think this would work, but it does not. I have tried to put in a onclick event in vb.net for the web form but it does not work. how can I get this to work?
 
Make sure you have AutoPostback="True" on your checkboxes

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
May need to do this kind of client side but you can still add the code server side:

CheckBox1.Attributes.Add("onclick","document.getElementBy('" & CheckBox2.ClientID & "').disabled=(!this.checked);"
or
CheckBox1.Attributes.Add("onclick","document.getElementBy('" & CheckBox2.ClientID & "').disabled=(this.checked);"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top