mardi 8 août 2017

ASP.NET Checkbox.Checked is not working

in ASP.Net Webforms I have a checkbox and button.

<asp:CheckBox ID="checkBox" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Check" OnClick="Button1_Click"/>

I want to handle Checkbox's check status with button click. But it is only getting false value.

if (checkBox.Checked == (true))
{
    Label1.Text = "Selected";
}
else
{
    Label1.Text = "Not Selected";
}

After every click I am getting Not Selected in my label. I think this is so basic but now i couldn't fix.




Aucun commentaire:

Enregistrer un commentaire