How to apply External CSS to Html Helper Class Elements?


Problem :

I am using DropDownList(), TextArea(), TextBox(), ListBox() in my aspx page. I want to apply External CSS to it not inline CSS. And I don't want apply using Id/Class. So How to apply External CSS to HTML helper Class Element by its name?

Solution :

controls added using HTML helper class converts the controls them to simple HTML elements/controls.

If you are adding Html.Dropdownlist() it will get converted to <select/> only at last.

So for this simply apply your css on the <select/>.

and for future simply view PageSource from browser and you will come to know in which tag your control is getting converted and you can write your css for that tags...

    CSS Howto..

    how to change the CSS linear-gradien backgroundt height (thickness)?

    How to avoid width calculation, can this be done with just CSS?

    how to define style for a group of child elements from parent element's style?

    How to set border to 0 in this table

    How to disable JS function via CSS for certain page?

    How to create a QT plugin that customizes UI?

    How to achieve “background-image: cover” CSS effect for dynamic images?

    Speechbubble tooltip in CSS - how to move the arrow

    How to make round corners to both inside of a box and its border?

    How to make corners of progress bar round in css

    How to right align last two columns of a table with CSS

    How I can change the CSS properties of HTML elements in run time using JavaScript or PHP?

    CSS, borders: How do I prevent a border added to a table cell from displacing neighboring cells?
    I think you'll either need to size all non border cells wider and higher by the width of the line around it. or you given them all borders and set...
    Read more

    how to align image and text when floating to image

    How to prevent mobile browser micro-shrinking HTML block level elements?

    How to attach click event to a css styled checkbox

    How to make video responsive for all the screen sizes?

    CSS - how do I float another div over another without overlapping

    how to make image in over than other like this

    How can i stop my text css from over-riding my form on my blog?

    How to Tie Events to CSS

    CSS Fixed width right, fluid left, right div is first in html. How do I keep left from collapsing

    How do I customize