James Sherburn
James Sherburn

Reputation: 99

Apply CSS style attributes to @Html.TextBox

I'm working on an MVC application.

I have the following line of code:

@Lines.Html.TextBox(p => p.Dscription)

How can apply my own style to this text box? i.e. change the width?

Upvotes: 0

Views: 1804

Answers (3)

Ala
Ala

Reputation: 1503

There is an overload of (Textbox) html helper:

@Lines.Html.TextBox(p => p.Dscription, null, new { @class = "css-class" })

Upvotes: 0

beauXjames
beauXjames

Reputation: 8428

You can just append a generic object as the second parameter which contains the appropriate attributes ::

@Lines.Html.TextBox(p => p.Description, new { @class = "className", @style = "width: 200px" }

Upvotes: 1

Julito Avellaneda
Julito Avellaneda

Reputation: 2385

add another param to the helper:

@Lines.Html.TextBox(p => p.Dscription, new {@class="clasecss", more properties})

Regards,

Upvotes: 0

Related Questions