How to override CSS for TextBoxFor field?


Tags: html,css,asp.net-mvc,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 to make this type of image popping out of box using XHTML css

    How to use a variable for image paths with less mixins

    How to best make a hover navbar?

    How to overlap a border in CSS in order to create tabs?

    How to make a braille interface for our website

    How to edit CSS file in Objective-C

    How To Make iPhone6 Plus Landscape Mode Work Better with Bootstrap3?

    how i can make slideshow, get information(image, title , content) from database? [closed]

    how to organize all js, css, php and html code?

    How to make css max width in IE6 and 7?

    How to select element by order ? - Css

    How to keep DIV from overlapping?

    How to make a div fall on hover and stay at at the bottom of the page using jquery or css?

    How to convert css long to css one line style with Notepad++

    How to show an image on html page using only css?

    Adding some automatic versioning to CSS files. How come I'm not able to pull assembly info?

    How can I make a fade in function without using jQuery like this? (JavaScript)

    CSS: How to position an to the middle of the parent element [closed]

    Is it possible to show webpage in a window from my Chrome extension, only using JS, HTML and CSS?

    How to set icon of an page using CSS

    Bootstrap: How to make repeated divs go around a fixed div

    How to use JavaScript OnResize with delay or less processing intensive

    How to make Wrapper div contain only non-overflowing divs

    How to change the text color of the clicked row of table with css and jquery

    How to chose which CSS rule to use from multiple style sheets

    Google fonts and twitter bootstrap 3: where should I load the fonts, and how to use it in css file?

    How to display a background image with a:hover

    How to make the parent div adjust in size to contain the CSS-Rotated child div?

    How do I make my div scale to larger than it's original size using css animation?

    I would like to know how can i do tab spaces after a word so that the pattern that comes after that would be align with each other