How to change width @Html.TextBox

Total Post:134

 7755  View(s)
Rate this:

how do you change the width of a textbox in an View

i want to have these fields side by side and the state textbox much shorter width


                <label for="city">City:</label>
                @Html. TextBoxFor("city")
                <label for="state">State:</label>
                @Html. TextBoxFor("state")



none of the below answers seem to work for me. I noticed that in site.css i see this:

fieldset p 

     margin: 2px 12px 10px 10px;

fieldset label
     display: block;

fieldset label.inline
     display: inline;

     font-size: 1.1em;
     font-weight: 600;
     padding: 2px 4px 8px 4px;

    width: 200px;
    border: 1px solid #CCC;

    width: 200px;
    border: 1px solid #CCC;

how do i override this behavior for one field (textbox)

  1. Post:101

    Re: How to change width @Html.TextBox

    Hey Tanuja!

    Here I would use the helper signature which is takes HTML attributes and assign it a CSS class. You would then use CSS to achieve the desired look and feel.

     @Html.TextBoxFor( "state", null, new { @class = "small-input" } )

      Modified On Mar-31-2018 03:24:00 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.