Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net-mvc How to change width Html.TextBox

Tags:

how do you change the width of a textbox in an asp.net-mvc View

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

            <p>
                <label for="city">City:</label>
                <%= Html.TextBox("city")%>
                <label for="state">State:</label>
                <%= Html.TextBox("state")%>
            </p>

EDIT:

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;
}

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

input[type="text"] 
{
    width: 200px;
    border: 1px solid #CCC;
}

input[type="password"] 
{
    width: 200px;
    border: 1px solid #CCC;
}

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

like image 580
leora Avatar asked Jun 30 '09 13:06

leora


2 Answers

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

 <%= Html.TextBox( "state", null, new { @class = "small-input" } ) %>
like image 107
tvanfosson Avatar answered Sep 28 '22 12:09

tvanfosson


<%= Html.TextBox("state", null, new { @style = "width: 300px;" })%>
like image 40
Jeff Widmer Avatar answered Sep 28 '22 12:09

Jeff Widmer