TextAreaFor Cannot Set Width

前端 未结 5 1461
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 06:24

I cannot set the width or cols in atextarea. Rows/Height works just fine. can someone please help thanks!

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken(         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 06:38

    so I figured it out, I believe this is a problem with bootstrap imported to a ASP.NET MVC5 project. The answer is easy though. Just set CSS too

        max-width: 1000px;
        width: 1000px;
    

    That fixes it for all datatypes. Textarea, input, etc.

    **** UPDATE 8/26/2014 ****

    Changed my answer to reflect on a comment posted. Use percentages rather then px to keep responsiveness. The CSS should be:

        max-width: 100%;
        width: 100%;
    

    **** UPDATE 8/29/2016 ****

    This was fixed with Bootstrap 3. Add the class form-control which applies the above styling

         @Html.TextAreaFor(x => x.Note, new { @class = "form-control", rows = "3" })
    

提交回复
热议问题