C# 从CheckBox控件获取值

C# 从CheckBox控件获取值,c#,asp.net,checkbox,webforms,C#,Asp.net,Checkbox,Webforms,在选择复选框控件之前,如何从该控件获取值??它没有.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方法

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?
试试这个:
((复选框)(c)).Checked.ToString()

您可以尝试以下方法:

<input id="chkBox1" name="chkbo" type="checkbox" value="myvalue" runat="server" />

您必须获得
属性

string Value = checkbox1.Attributes["Value"];

根据复选框的状态返回true或false

复选框的文本和值有什么区别?我认为是一样的。文本是用户在浏览器上看到的文本。。。该值将是您所说的true false?否,例如,如果.asp中的代码为:
我想获取“MYVALUE”,则Checkbok将仅返回true或false布尔值作为值。它不能返回字符串或任何其他值。它返回假值。这是复选框中“值”的含义。请在aspxYour checkbox控件中的复选框上尝试AutoPostBack=“true”
string Value = checkbox1.Attributes["Value"];
myCheckbox.Checked