我在html中有代码:
<form runat="server">
<table>
<tr>
<td>
From Date:
</td>
<td>
<input type="text" runat="server" id="txtDate" placeholder="YYYY-MM-DD"/>
</td>
</tr>
<tr>
<td>
Show Data:
</td>
<td>
<input type="radio" id="rbShowDataYes" name="chShowData" value="1" checked="checked"> Yes
<input type="radio" id="rbShowDataNo" name="chShowData" value="0"> No
</td>
</tr>
...
</form>
在c#中,当我尝试到达txtDate.Value
时,它正在运行,但是rbShowDataYes.Checked
无效,表示rbShowDataYes
不在当前上下文中。我的错误在哪里?
答案 0 :(得分:0)
string value=chShowData.SelectedItem.Value.ToString();
bool isChecked = radioButton1.Checked;
if(isChecked )
value=radioButton1.Text;
else
value=radioButton2.Text;