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 ButtonClick
. 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.
Is there anyway to fix this.
Not sure if this has been solved, this is beacause Autopostback is not enabled. Change it to below
asp:CheckBox ID="checkBox" AutoPostBack=“true” runat="server" ```