Benk
Benk

Reputation: 1312

MVC3 textbox - create custom width

Hi I want to make my textbox's width longer.

The view that is generated, uses @Html.EditorFor which I noticed I can't modify nor I can add css style to it.

So I checked, TextAreFor and it works but it creates a scrollbar since it is a textarea

e.g.

@Html.TextAreaFor(model => model.Name, new { cols=50, @rows=1 })

How would I remove the scrollbar? so it looks like it is a textbox? or is there another way to generate a textbox with a custom width?

Thanks,

Upvotes: 0

Views: 1711

Answers (3)

Miroslav Holec
Miroslav Holec

Reputation: 3217

Maybe

@Html.TextBoxFor(m => m.Name, new { @style="width:150px; height:50px; overflow:hidden;" })

Upvotes: 0

Romias
Romias

Reputation: 14133

Use a CSS class with the following statement:

overflow:hidden

Upvotes: 0

Shyju
Shyju

Reputation: 218702

You can use TextBoxFor HTML Helper method for generating a input element with a custom class like this

  @Html.TextBoxFor(m => m.Name, new { @class="yourCustomClass" })

and now you can define your custom styles in this class

.yourCustomClass
{
  width:340px;
}

Upvotes: 1

Related Questions