当前位置: 代码迷 >> ASP.NET >> MVC中Html.EditorFor宽度及高度怎么设定
  详细解决方案

MVC中Html.EditorFor宽度及高度怎么设定

热度:161   发布时间:2013-02-25 00:00:00.0
MVC中Html.EditorFor宽度及高度如何设定?
Html.EditorFor中如何设定高度及宽度,<%: Html.EditorFor(model => model.Content)%>
如何生成像这样的格式:<textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>

<%: Html.EditorFor(model => model.Content, new { @style="width:200px;height:150px"}})%>我这样设定不起作用,只用Html.TextBoxFor有效。

------解决方案--------------------------------------------------------
帮你看了下Html.EditorFor的方法签名:
http://msdn.microsoft.com/en-us/library/system.web.mvc.editorextensions.editorfor.aspx
其中并没有类似Html.TextAreaFor的Object htmlAttributes参数
我在生成textarea的时候,是这样用的:
C# code
<%=Html.TextAreaFor(Model => Model.PrjFundsInfo, new { rows = "8", style = "width:99%" })%>
------解决方案--------------------------------------------------------
<%= Html.EditorFor(model => model.Content, new { width="200px",height="150px"})%>
------解决方案--------------------------------------------------------
探讨
<%= Html.EditorFor(model => model.Content, new { width="200px",height="150px"})%>

------解决方案--------------------------------------------------------
哥们。。。仔细看方法签名啊,如果像7楼这样写:
C# code
<%= Html.EditorFor(model => model.Content, new { width="200px",height="150px"})%>
  相关解决方案