Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何基于枚举单选按钮选择隐藏输入字段.NET MVC_C#_Jquery_Razor_Model View Controller_Enums - Fatal编程技术网

C# 如何基于枚举单选按钮选择隐藏输入字段.NET MVC

C# 如何基于枚举单选按钮选择隐藏输入字段.NET MVC,c#,jquery,razor,model-view-controller,enums,C#,Jquery,Razor,Model View Controller,Enums,我使用MVC Razor技术在C#中开发了一个页面,我的代码如下 <div class="col-md-4"> <label for="" class="control-label"> IDMS Reference <font color="red">*</font></label><br /> <div clas

我使用MVC Razor技术在C#中开发了一个页面,我的代码如下

<div class="col-md-4">
                <label for="" class="control-label">
                    IDMS Reference <font color="red">*</font></label><br />
                 <div class="radio col-md-4">
                     @Html.EnumRadioButtonFor(m => m.enumIDMSReference, false).DisableIf(() => 
                                                                          Model.IdmsRef == 2)

                </div>
在这里,如果我们单击不适用单选按钮,则IDMS参考号输入字段应禁用,而输入IdmsRefNo字段应仅为适用单选按钮启用,因此如何在JQuery或任何其他解决方案中执行此操作?。
请任何人帮助

如果我正确理解了您的问题,您希望根据所选的单选选项禁用字段。您可以绑定单选按钮的更改事件,并相应地禁用/启用文本框

您可以像这样迭代枚举值(我不检查空值,您可以自己做):

@foreach(Enum.GetValues(Model.enumIDMSReference.GetType())中的var值)
{
var memInfo=Model.enumIDMSReference.GetType().GetMember(value.ToString());
var attributes=memInfo[0]。GetCustomAttributes(typeof(DescriptionAttribute),false);
变量说明=((DescriptionAttribute)属性[0])。说明;
@RadioButton(m=>m.enumIDMSReference,值);
@标签(说明);
@Html.Raw(“
”); }

根据enumIDMSReference的值,您可以通过在默认服务器端禁用/启用文本框来进一步扩展此功能。

您能给出一个示例代码吗?请检查此链接,我在该链接中找不到解决方案。如果你能帮忙,请帮帮我。
 <div  class="col-md-4">
                <label for="" class="control-label">
                    IDMS Reference Number <font color="red">*</font></label><br />
                @Html.TextBoxFor(m => m.IdmsRefNo, new { @class = "form-control"  
                                            }).DisableIf(() => Model.InwardBranch == true)
</div>
public enum enumIDMSReference
{
    [Description("Applicable")]
    Applicable = 1,

    [Description("Not Applicable")]
    NotApplicable = 2,

}
$('input[name="enumIDMSReference"]').change(function() {
    if ($(this).is(':checked') && $(this).val() == 'NotApplicable') {
        $('#IdmsRefNo').attr('disabled', 'disabled');
    } else {
        $('#IdmsRefNo').removeAttr('disabled');
    }
});
@foreach (var value in Enum.GetValues(Model.enumIDMSReference.GetType()))
{
    var memInfo = Model.enumIDMSReference.GetType().GetMember(value.ToString());
    var attributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
    var description = ((DescriptionAttribute)attributes[0]).Description;

     @Html.RadioButtonFor(m => m.enumIDMSReference, value);
     @Html.Label(description);
     @Html.Raw("<br />");
}