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 know which CSS is overriding my background image?

    How to hide hr inside the last li using css

    How to add and remove a current state to a link when another is clicked using jQuery

    How to change size of text input but not textarea in jquery mobile

    How to use two JavaScript (.js) files on one website?

    How to resize parent div while keeping dynamic child divs 100% height

    How to stay on selected tab after refresh?

    How to remove the text from this html

    How to get the root directory of wordpress in css

    How to set border's thickness in percentages?

    How to deselect using :not according to css property and value

    How do I change the colour of 'and one other person like this' when I've added it to my site?

    How many digits after the decimal point are interpreted in stylesheet rules?

    How to align multiple columns in bootstrap 3 carousel?

    CSS: How to define a centered div with endless vertical borders and an initial height of 100%?

    How to create an easy responsive grid with one column and two boxes?

    CSS: How to align text, next to image inside a span?

    How to replace non-existing images with a default one in css?

    How do I align these pictures vertically?

    How to import css from libraries via postCSS?

    How to put text on placeholder image

    How do i add a fading border to my nav bar CSS

    How can I debug twitter bootstrap v4-alpha grid? col-sm-offset-* not working

    how to rewrite relative url in minified css with cssmin?

    How can I make my icon
    s show up next to each other, rather than underneath each other?

    How to have a background image properly fade in with CSS

    How to set just a percentage of a color in CSS?

    jQuery: How do I target the clicked element when they all share the same CSS class?

    Using CSS to style a Sencha Touch form - how do I find the elements?

    How to highlight a table row upon hover conditionally based on table cell values with CSS and jQuery?