Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.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
如何设置引导类和Html属性?_Html_Css_Asp.net Mvc_Twitter Bootstrap_Asp.net Mvc 4 - Fatal编程技术网

如何设置引导类和Html属性?

如何设置引导类和Html属性?,html,css,asp.net-mvc,twitter-bootstrap,asp.net-mvc-4,Html,Css,Asp.net Mvc,Twitter Bootstrap,Asp.net Mvc 4,我需要构建一个带有引导样式和一些HTML自定义属性的输入文本区域。这是我的密码: @Html.EditorFor(model => model.Comments, new { style = "color: red; width: 400px", @class = "form-control", placeholder = "Enter detailed comments..."), type = "text" }) 我的模型数据来自具有以下数据注释的viewmodel:

我需要构建一个带有引导样式和一些HTML自定义属性的输入文本区域。这是我的密码:

        @Html.EditorFor(model => model.Comments, new { style = "color: red; width: 400px", @class = "form-control", placeholder = "Enter detailed comments..."), type = "text" })
我的模型数据来自具有以下数据注释的viewmodel:

[DataType(DataType.MultilineText)]
public string Comments{ get; set; }
不幸的是,如果这是一个TextBoxFor,它的工作方式与我的工作方式不同。EditorFor没有设置样式,在sceen上显示一个简单的小默认HTML


我想知道如何解决这个问题?我使用的是MVC4,现在无法转到MVC5.1(这是一项要求。我知道MVC5.1在这方面有一些改进)。

既然您使用的是
multilitext
属性,我想您想要一个textarea?您只需将
编辑器for
调用更改为
文本区域for

@Html.TextAreaFor(model => model.Comments, new { style = "color: red; width: 400px", @class = "form-control", placeholder = "Enter detailed comments..."), type = "text" })
您可以覆盖(
~/Views/Shared/EditorTemplates/multilitext.cshtml
):


@Html.TextArea(
"", 
ViewData.TemplateInfo.FormattedModelValue.ToString(),
视图数据
)
这是一个无耻的问题

<someboostraphtmlelements>
@Html.TextArea(
    "", 
    ViewData.TemplateInfo.FormattedModelValue.ToString(),
    ViewData
)
</someboostraphtmlelements>