Asp.net MVC5与引导EditorFor大小 [英] Asp.net MVC5 with Bootstrap EditorFor size

查看:249
本文介绍了Asp.net MVC5与引导EditorFor大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些修改,使到使用EditorFor(使用MVC5)一种形式,我无法找到设置文本框的大小的方式...
我试着用硬盘的方式:

I have some modifications to bring to a form which use EditorFor (and using MVC5) and I can't find the way of setting the size of the text box ... I tried the hard way with:

@Html.EditorFor(model => model.Nom, new{@style="width:400px"})

但这并没有工作..
有一个简单的方法?

But this did not work.. Is there an easy way?

推荐答案

在MVC高达5版本,EditorFor不允许您指定这样的HTML元素。它只能在非编辑的环境中使用,像TextBoxFor等...

In MVC up to version 5, EditorFor does not allow you to specify html elements in that way. It can only be used in non-editor contexts, like TextBoxFor, etc...

在MVC 5.1它们添加到指定的编辑器模板的HTML属性的能力,你现在可以这样做:

In MVC 5.1 they added the ability to specify html attributes in Editor templates, and you can now do this:

@Html.EditorFor(model => model, new { htmlAttributes = new { @class = "form-control" }, })

这篇关于Asp.net MVC5与引导EditorFor大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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