如何在选中之前从CheckBox控件中获取值?它没有.Value方法。
else if (c.GetType() == typeof(CheckBox)) // c is control
{
string textValue= ((CheckBox)(c)).Text; // here I take the text
string value= ((CheckBox)(c)).????; //how should I take the value?
你必须得到Value
属性。
string Value = checkbox1.Attributes["Value"];
试试这个:((CheckBox)(c))。Checked.ToString()
myCheckbox.Checked
根据复选框的状态返回true或false。
你可以尝试这个:
<input id="chkBox1" name="chkbo" type="checkbox" value="myvalue" runat="server" />
然后你可以从后面获取值字段:
chkBox1.value;