Why can't I set the value to asp: CheckBox?
No Value Attribute:
<asp:CheckBox ID="CheckBox1" runat="server" /> and on standard HTML this is allowed:
<input type="checkbox" ID="CheckBox1" value="My Valyue" /> why?
The Text property is used to render the label for this flag.
The control has an InputAttributes property, which you can add:
myChk.InputAttributes.Add("value", "My Value"); I believe that if you simply add the value attribute to the markup, this will also be populated.
You can access the following value:
myChk.InputAttributes["value"]; To answer the question of why value not an assembly attribute in a CheckBox control:
A CheckBox alone (just by itself) does not need value. By definition, it is logical and is identified by its identifier. All you have to do is check if it has been checked or not.
The value comes into play when you group the flags, and for this there is a control - CheckBoxList , which uses a ListItem - each ListItem has a value property.