Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Enable/Disable ASP.NET controls

Hi! I'am new to ASP.NET and having problems with my project. Here's the scenario. I want a DropDownList ASP.NET Control to be enabled/Disabled whenever I check/uncheked a check box. I like it to be on the client side and I rhink JavaScript will do, but I don't know how. Pls help! Thanks
[302 byte] By [hallie] at [2007-11-11 8:26:49]
# 1 Re: Enable/Disable ASP.NET controls
Hey well I'm not sure exactly what you want to do but I think it goes something like this...

Say you have a checkbox named cxBox and a dropdown called dpDown then you would double click on the check box (in VStudio) and it'll create the following function

Protected Sub cxBox_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cxBox.CheckedChanged

If Me.cxBox.Checked Then
Me.dpDown.Visible = True
Else
Me.dpDown.Visible = False
End If

End Sub


bold needs to be added by you. If you need to be able to enable or disable a control just add the disable/enable command in the visible area.

Hope this helps

Jackie
partyk1d24 at 2007-11-11 23:13:15 >
# 2 Re: Enable/Disable ASP.NET controls
I already done that! but the dropdown list doesn't change. I think the webform still needs to be refreshed if I do that.
hallie at 2007-11-11 23:14:11 >