【问题标题】:how to to use html control radio button in asp.net如何在asp.net中使用html控制单选按钮
【发布时间】:2015-10-16 06:41:26
【问题描述】:

我有 2 个单选按钮,我想设置一个特定条件,例如,

如果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>   

【问题讨论】:

  • 就这样吗?请分享您在 javascript 中尝试过的内容。

标签: asp.net html c#-4.0


【解决方案1】:

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

例如

string strPlace='';

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

并根据所选单选按钮上的值使用您的代码。

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.
}

【讨论】:

    猜你喜欢
    • 2017-06-11
    • 2013-06-11
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    相关资源
    最近更新 更多