c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
asp.net MVC

How to apply css for dropdownList in MVC .net?

| | ASP-NET , MVC

First, I have created a controller using entity framework but the generated result was not in the appropriate form. So, I applied Css class and header name for the DropdownList. 

Following code is generated automatically, 

@Html.DropDownList("DepartmentId", String.Empty)

 I have created a css class with style property and apply to dropdrownlist. 

<style type="text/css">
    mydrowpdownstyle {
        background-color: blue;
        color:white;
    }
</style> 

Solution: 

@Html.DropDownList("Category", null, "Select Category", new { Class = "mydrowpdownstyle" })