0

It seems that ASP NET MVC is having problem to display the correctly when I use TextAreaFor. Is anyone there having this problem?

This is how the browser is displaying it

Notice that the last TextArea is being displayed just fine.

This is how the code is my code

Notice that the TextArea below* the red retangular is being displayed just fine.

Answer

    textarea
    {
        display: block;
        width: 100%;
        height: 34px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.428571429;
        color: #555555;
        vertical-align: middle;
        background-color: #ffffff;
        border: 1px solid #cccccc;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
        -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 
         0.15s;
        transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
    }
8
  • What's the problem? Commented May 1, 2017 at 21:04
  • @Seano666, I don't know why when I use TextAreaFor on asp net mvc the CSS class "form-control" don't work. Commented May 1, 2017 at 21:08
  • You haven't posted any CSS code. What happens when you inspect the TextArea in the browser developer tools. Does it have the CSS class that you expect? Commented May 1, 2017 at 21:11
  • I saw a difference between both TextArea, but this html/css code is generated by Razor. Sorry I can't post the full css that I'm using because it has more than 6k lines. i.stack.imgur.com/8tL9Z.png @Seano666 Commented May 1, 2017 at 21:17
  • This is a better view of the generated HTML code, i.sstatic.net/ZPScn.png Commented May 1, 2017 at 21:26

1 Answer 1

2

I think you typoed the TextAreaFor:

@Html.TextAreaFor(model => model.Titulo, new { htmlAttributes = new { @class = "form-control" } })

Should be

@Html.TextAreaFor(model => model.Titulo, htmlAttributes: new { @class = "form-control" } )

or even

@Html.TextAreaFor(model => model.Titulo, new { @class = "form-control" })
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for you help @Frank Witte, but my problem was with the default CSS of ASP NET MVC Application gerenerated for VisualStudio.

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.