How to override CSS for TextBoxFor field?

Tags: html,css,,html.textboxfor,html.textbox

Problem :

Have the following class in Site.css:

input[type="textbox"].TextBoxAsLabel {
     background:#f2f3f3  !IMPORTANT;

want to override default background for TextBoxFor field in Edit.cshtml

@Html.TextBoxFor(model => model.ClientNumber, new {@readonly = "readonly", @class = "TextBoxAsLabel"})

and it still uses default white background. What should I change?

Solution :

I realized that problem was in location of CSS file. Now code in separate styles.CSS is:

  .message-label {
    background-color: #f2f3f3;

Styles.css is referenced in _Layout.cshtml:

 <link href="@Url.Content("~/Content/styles.css")" rel="stylesheet" type="text/css" />

and in CHTML:

 @Html.TextBoxFor(model => model.ClientNumber, new {@readonly = "readonly", @class ="message-label"})

and it works!

    CSS Howto..

    How do I make cards of different heights fill gap in css? [duplicate]

    JavaFX: How do I set a Background Image in code?

    how to not inherit? or how to reset inherited width to the value before? (css)

    How do I add the date a blog post was created in place of a bullet point under list-style-type?

    PNG image showing up with white background even though it has a clear background

    How to change cursor on the NextGen Gallery Slideshow in Wordpress

    (CSS) Set Id for Class How to Use

    HTML table-cell how to set width

    How to Make a materialize CSS button's width same as col s12?

    How can I add the following css code to my page header from functions.php?

    How to display a division over other element

    How to add an informative popup over a given text

    How to add a ToolTip for an icon inside my CSS file

    jQuery - How to improve the logic for toggling inline css and class name while clicking activated buttons and hovering non-activated buttons?

    How to == Model Method Class in Helper for CSS?

    How to make a different background for each link from a navbar? [closed]

    How to background css with php variable

    How to make the footer stick to the bottom?

    CSS: How to set image width larger than the container's [closed]

    jquery width toggle animation is showing vertical cells during animation takes place

    How to position css sprite play button within video image

    How do I make an element the height of the browser window?

    How can I hide slide menu in appcelerator?

    How to target the first-child of an optgroup with css or jquery

    How to make an element remain inline

    How to make background image with aspect ratio in html and css [closed]

    How to attach click event to a css styled checkbox

    How to set Highcharts data series in x-axis using crosshairs?

    How to make one circle inside of another using CSS

    How to add CSS dynamically to a controller in SAPUI5