I cannot set the width or cols in atextarea. Rows/Height works just fine. can someone please help thanks!
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.TextAreaFor(model => model.Comments, new {cols=60, rows=10})
@Html.HiddenFor(model => model.UserName, new { UserName = @User.Identity })
<div class="form-group">
<div class="col-md-10">
<input type="submit" value="Submit Feedback" class="btn btn-default" />
</div>
</div>
}
Any advice or tips would be greatly appricated! thanks
The HTML rendered is (I removed name and value text for security reasons:
<form action="/feedback/create" method="post"><input name="" type="hidden" value="">
<textarea name="Comments" id="Comments" rows="10" cols="60"></textarea>
<input name="UserName" id="UserName" type="hidden" value="" username="System.Security.Principal.WindowsIdentity">
<div class="form-group">
<div class="col-md-10">
<input class="btn btn-default" type="submit" value="Submit Feedback">
</div>
</div>
EDIT:
I can set the width of the textarea via CSS but only to a certain exten ( maybe 15% of the screen)
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" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With