Tuesday, 27 August 2013

Input control type Checkbox always true

Input control type Checkbox always true

I have searched all the topics discussing this issue and cant seem to find
one that explains the issue using Asp.net C#, everything is either
javascript or MVC or PHP my reasoning for opening a new question regarding
this.
I have 2 input control type checkbox
<input runat="server" type="checkbox" name="chkChildSexMale"
id="chkChildSexMale" />
<input runat="server" type="checkbox" name="chkChildSexFemale"
id="chkChildSexFemale" />
My CodeBehind is
if (chkChildSexMale.Checked)
{
do something
}
else if (chkChildSexFemale.Checked)
{
do something else
}
The issue is that no matter what is checked the
if(chkChildSexMale.Checked) is always true even though it is not checked.
What am I doing wrong?

No comments:

Post a Comment