How to add css class?


Tags: css,asp.net-mvc-3

Problem :

@Html.EditorFor(model => model.Screen.Description)

How to add a class or some other attributes to the generated input?



Solution :

The built-in editor template is too generic (it can display arbitrary objects) for such a concept to make sense. You could either

  1. Write your own editor template
  2. If it's only a single property you're displaying you could use a more specific helper method such as Html.TextBoxFor():

    @Html.TextBoxForm(m => m.Screen.Description, new { @class = "myClass" })
    

    CSS Howto..

    How float divs inside a td

    How to add an url to image by css?

    How to use CSS calc according to a certain amount of li's?

    How to use “all” property in CSS

    how to flip the div using css?

    How to set height of child div while hovering over a parent div in css?

    How to center two square blocks in page?

    How to horizontally center absolute text?

    How to disable animation in a specific element in CSS

    How to see the style of the thumb of range input in Chrome developer tools?

    How do I absolutely position a relatively positioned element?

    how to position subheader right under header [closed]

    how to set transform for div without effect on background image?

    Height isn't showing up full on everything except Chrome

    How to activate jQuery function with img instead of button?

    how to get a rounded corner table with a body in different color with CSS?

    How can I align unsorted list horizontly ?

    How to make an inline element appear on new line, or block element not occupy the whole line?

    CSS triangle how to remove white space on the right

    How to replace only the text of this element with jQuery?

    How to apply different css style for IE 10 and 11 only?

    onsen ui 2 : how to implement android style scrollable tabbar?

    How do you make a sticky nav bar change colour when you scroll to a desired div?

    How to create custom buttons with arrows for twitter bootstrap?

    How to center a relative div in my case?

    How can i add arrow to image

    How can I prevent a bookmark from changing style when moving the cursor over it?

    How to make a menu have submenus in pure CSS

    How to denote common class names with slight numeral changes into one - CSS shorthand?

    HTML: How to add an image using CSS as linked style sheet