I have problem with determine if checkbox is checked on my webpage build in ASP.NET. When I render webpage in Page_Load method I check some of checkbox using code like:
checkbox1.Checked = true;
On page I have button to process data in form, on click in this button i check if checkbox was checked:
if(checkbox1.Checked == true)
{
//do something
} else {
//do something else
}
But i found that value which I get from Checked property is always same as I set in first step. That property never returns value of current state of CheckBox. And here is my question: Why?
I menaged to bypass that problem by setting checked in different way:
checkbox1.Attributes.Add("checked","true");
I don't like when something works but I don't know why so please give me advise what I'm misunderstanding.
problem that can no longer be reproducedThe code as-is is kinda ok and we can't tell for sure what's wrong. It's most likely something really trivial that could have been resolved by simply reading through the most basic tutorials...