Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Width of input fields using EditorFor in MVC3

Tags:

asp.net-mvc

I just had some great advice on how to set the width of an input field in MVC:

@Html.TextBoxFor(model => model.Status.RowKey, new { size = 200, disabled = "disabled", @readonly = "readonly" })

Now I hav tried it for another type of field but it doesn't work:

@Html.EditorFor(model => model.Status.BrowserTitle, new { size = 80 })

I would also like to set this for 80 characters but when I do this the source does not change and does not show 80.

Bev

like image 885
JudyJ Avatar asked Jan 20 '23 19:01

JudyJ


1 Answers

If you need to use EditorFor and not TextBoxFor and have multiple editors on the page, but only need to change the width of specific ones... The easiest what is to add a css style to the class ID as such:

<style type="text/css">
    input#Status.BrowserTitle { width: 80px; }
</style>
like image 88
Mike B Avatar answered Feb 03 '23 07:02

Mike B