Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set width of html.textboxfor?

I have a <%= Html.TextBoxFor(user => user.Name) %> and it has standart width.

What should I do to make textbox wider?

like image 799
r.r Avatar asked Dec 05 '22 01:12

r.r


2 Answers

You can do this to add a CSS class called singleTextBox, and then you can assign a width in your style sheet:

<%= Html.TextBoxFor(model => model.UserName, new { @class = "singleTextBox" }) %>

In your style sheet:

.singleTextBox {
    width: 12em;
}
like image 99
D'Arcy Rittich Avatar answered Dec 27 '22 11:12

D'Arcy Rittich


you can also do using css style, its that simple and worked great for me

@Html.TextBoxFor(model => model.UserName, new { style = "width: 250px;" })

got this idea from Darin's answer for DropdownList width.

hope helps someone.

like image 40
Shaiju T Avatar answered Dec 27 '22 13:12

Shaiju T