在MVC / Razor中的Disbale EditorFor [英] Disbale EditorFor in MVC/Razor

查看:120
本文介绍了在MVC / Razor中的Disbale EditorFor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让EditorFor输入禁用



i尝试使用下面的功能不起作用



@ Html.EditorFor(model => model.TaskName,new {disabled =disabled,@ readonly =readonly})

解决方案

EditorFor html helper没有带HTML属性的重载。在这种情况下,您需要使用更具体的内容,如TextBoxFor:



< div  class  =   editor-field  >  
@ Html.TextBoxFor(model = > model.userName, new
{disabled = disabled,@ readonly = readonly})
< / div >



希望这有助于


disable属性不返回值read只能正常工作


How Can i make the EditorFor input disabled

i have tried using the below which doesn't work

@Html.EditorFor(model => model.TaskName, new { disabled = "disabled", @readonly = "readonly" })

解决方案

The EditorFor html helper does not have overloads that take HTML attributes. In this case, you need to use something more specific like TextBoxFor:

<div class="editor-field">
    @Html.TextBoxFor(model => model.userName, new 
        { disabled = "disabled", @readonly = "readonly" })
</div>


Hope this helps


The disable attribute does not return a value read only works OK though


这篇关于在MVC / Razor中的Disbale EditorFor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆