简体   繁体   English

如何在asp.net中使用html控件单选按钮

[英]how to to use html control radio button in asp.net

I have 2 radio buttons and I want to set a specific condition like, 我有2个单选按钮,我想设置一个特定条件,例如,

if value=1 then save a file on abc location and if value=2 then save the file xyz location 如果value=1则将文件保存在abc位置;如果value=2则将文件保存在xyz位置

<tr>
    <td class="case_heading" height="20" width="150" align="right">Mode :&nbsp;&nbsp;&nbsp;</td>
    <td class="case_txt" height="20" width="250" align="left">
    <input type="radio" name="rbMode" checked value="1" onclick="javascript:GetModeValue(this.value);" />Assignment
    <input type="radio" name="rbMode" value="2" onclick="javascript:GetModeValue(this.value);" />De-Assignment
    </td>
</tr>   

try using Request.Form["radion_button_name"] 尝试使用Request.Form["radion_button_name"]

eg 例如

string strPlace='';

if (Request.Form["rbMode"] != null)
 {
     strPlace = Request.Form["rbMode"].ToString();
 }
//=strPlace will return Null if No radio button is selected.

and use your code base on the value on selected radio button . 并根据所选单选按钮上的值使用代码。

if(strPlace=='1')
{
//save image in location 1
}
else if(strPlace=='2')
{
//save image in location 2
}
else
{
//error you have to select the location type using radio button.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM