I have the following line in my view:
<div class="editor-field">
<%= Html.TextBoxFor(m => m.Description)%>
</div>
How do I define the width of the text box?
I have the following line in my view:
<div class="editor-field">
<%= Html.TextBoxFor(m => m.Description)%>
</div>
How do I define the width of the text box?
You can attach it as an attribute. Try this:
<div class="editor-field">
<%= Html.TextBoxFor(m => m.Description, new { style = "20em;" })%>
</div>
A reusable solution is to set the width in your css file
.wide
{
width: 300px;
}
then set it using the markup above
<%= Html.TextBoxFor(m => m.Description, new { @class= "wide" })%>
This worked for me for the one-offs, pretty verbose though:
<%: Html.TextBoxFor(m => m.Description, new { style="width:50px;" })%>