Link to home
Start Free TrialLog in
Avatar of Stacey Fontenot
Stacey Fontenot

asked on

Get value of Checkbox using vb.net

I have a checkbox on a webform. I am using javascript to toggle a <div> hidden / show depending on the checkbox being checked. I need to determine whether the checkbox is checked in the codebehind. If I add runat="server", the javascript doesn't work, but I cant get the state of the checkbox from the codebehind. Anyone have an idea how to fix my issue. I'm using vb.net for code behind.

<input type="checkbox" id="cb01" />
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

You can add the runat="server" and then add an onClientClick event.

<asp:CheckBox runat="server" OnClientClick="alert(this.checked);" />

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stacey Fontenot
Stacey Fontenot

ASKER

I'm not using a panel.
Works great.