0

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 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?

3 Answers 3

2

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"});
Sign up to request clarification or add additional context in comments.

Comments

2

apply a css style~

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

which could look like this:

.foo {
    color: red;
}

Comments

0

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

#messageEntry textarea {width:500px} 

1 Comment

I'm sorry, but this didn't work. I'm not sure it was able to tie up TextAreaFor with textarea in the CSS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.