开发者

CSS Problem with Html.TextAreaFor

I have the following piece of code to give the User a text input box.

   <div id="messageEntry" class="grid_3 omega">
      <%= Html.TextAreaFor(x => x.Message) %>
   </div>

The input box is only displaying as a small area开发者_JAVA百科 which I would like to increase. Creating CSS for id="messageEntry" has no effect on the size of the box, so how do I increase the size?


You can specify the HTML cols and rows attributes using the following method signature:

HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IDictionary<String, Object>

This will allow you to do:

<%= Html.TextAreaFor(x => x.Message, new {rows = "50", cols = "50"});


apply a css style~

<%= Html.TextAreaFor(x => x.Message, 
    new { cols = "40%", @class = "foo" })%>

which could look like this:

.foo {
    color: red;
}


If you wanted to alter the appearance of the textarea via css, you could use something like this -

#messageEntry textarea {width:500px} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜