Tag: editorfor

MVC3 EditorFor只读

我想用编辑页面中的EditorFor进行只读。 我试图把只读和禁用作为: <div class="editor-field"> @Html.EditorFor(model => model.userName, new { disabled = "disabled", @readonly = "readonly" }) </div> 但是,它不起作用。 我怎样才能禁用编辑这个领域? 谢谢。

ASP.NET MVC中EditorFor()的Html属性

为什么我不能将html属性传递给EditorFor() ? 例如; <%= Html.EditorFor(model => model.Control.PeriodType, new { disabled = "disabled", readonly = "readonly" }) %> 我不想使用元数据 更新 :解决scheme是从视图中调用这个: <%=Html.EditorFor( model => model.Control.PeriodEndDate, new {Modifiable=model.Control.PeriodEndDateModifiable})%> 并在我的自定义EditorTemplates / String.ascx中使用ViewData["Modifiable"] ,其中我有一些视图逻辑,确定是否添加只读和/或禁用属性到input传递到EditorFor()的匿名对象是一个名为additionalViewData的参数和其属性将传递给ViewData集合中的编辑器模板。

Html5的占位符与.NET MVC 3razorEditorFor扩展?

有没有办法编写Html5占位符使用@ Html.EditorFor,或者我应该只使用TextBoxFor扩展 @Html.TextBoxFor(model => model.Title, new { @placeholder = "Enter title here"}) 或者是否有必要编写我们自己的自定义扩展,通过DataAnnotations(类似于这个 )可以使用'Description'显示属性? 当然,同样的问题也适用于“自动对焦”。

MVC4的DataType.Date EditorFor不会显示在Chrome中的date值,在Internet Explorer罚款

我在我的模型上使用DataType.Date属性,在我的视图中使用EditorFor。 这在Internet Explorer 8和Internet Explorer 9中工作正常,但在Google Chrome中显示的是dateselect器,而不是显示该值,只是以褪色的灰色文本显示“月/日/年”。 Google Chrome为什么不显示该值? 模型: [DataType(DataType.Date)] public Nullable<System.DateTime> EstPurchaseDate { get; set; } 视图: <td class="fieldLabel">Est. Pur. Date</td> <td class="field">@Html.EditorFor(m=>m.EstPurchaseDate)</td>