因为是转载文章 在此标明出处,以前有文章是转的没标明的请谅解,因为有些已经无法找到出处,或者与其它原因。

如有冒犯请联系本人,或删除,或标明出处。

因为好的文章,以前只想收藏,但连接有时候会失效,所以现在碰到好的直接转到自己这里。

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.html.editorextensions.editorfor.aspx其中并没有类似Html.TextAreaFor的Object htmlAttributes参数
我在生成textarea的时候,是这样用的:


<%=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楼这样写:

<%= Html.EditorFor(model => model.Content, new { width="200px",height="150px"})%>





 添加自定义样式

@Html.Label(Model.StoreMoney.ToString(),new {@class="balanceValue"})

添加属性

@Html.Label(Model.StoreMoney.ToString(),new {@style="width:30px;"})