3

USING : ASP .NET MVC 4 in one of my page i need a textarea with a certain width and height using html helper class. some of my code is given below :

    <div class="editor-label">
        @Html.LabelFor(model => model.MailSubject)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.MailSubject)
        @Html.ValidationMessageFor(model => model.MailSubject)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.MailBody)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.MailBody)
        @Html.ValidationMessageFor(model => model.MailBody)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Content)
    </div>
    <div class="editor-field1">
        @Html.EditorFor(model => model.Content)
        @Html.ValidationMessageFor(model => model.Content)
    </div>

I am wondering how I define the size(width/hide) of the editorfor(model.content)?

4

3 Answers 3

5

I realize this question is over a year old but just in case anyone is looking for the answer, here it is:

Html.TextAreaFor(model => model.Field, new { rows = "", cols = "", style = "width: 90%; height: 50px;" })

You can either apply the styles inline or use the class declaration. This will render the textarea on the page like so:

<textarea class="swiper-no-swiping" name="model.Field" cols="" rows="" style="width: 90%; height: 50px;"></textarea>
Sign up to request clarification or add additional context in comments.

Comments

2

I had this problem. I'm a newb, so I'm not really sure, but using the following I was able to adjust the height...

@Html.TextAreaFor(model => model.FullItinerary, 20, 10, null)

I still don't know how to adjust width, my current google mission...

Comments

0

Write a customer helper, or extend the functionality of the TextAreaFor helper.

Here is a resource to help you create a custom helper: http://www.simple-talk.com/dotnet/asp.net/writing-custom-html-helpers-for-asp.net-mvc/

Comments

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.