In this article, I will explain about how to implement Dropdown list in ASP.NET MVC. In traditional ASP.NET it is very easy to implement just by drag and dropping where we want. But in MVC we need some attention to create Drop Downlist.We have Dropdown list Html helper in ASP.NET MVC but we need to know how to bind data to Dropdown list Html helpers.we can implement Drop down list in ASP.NET MVC in 2 ways.

1.Using normal HTML Controls(select tag):

We can implement dropdownlist using HTML <select/> tag like below ExampleCode:

2.Using HTML helpers:

Method 1:

It is very easy to implement dropdownlist using normal html tags. But, if you want to bind data dynamically to the HTML tags it becomes complicated.To overcome and to make it easy to bind data to Html controls Microsoft introduced HTML helpers Methods.Here we are using Dropdown HTML helper to bind object data to Dropdownlist.

Advantages:1.It is also easy to implement.2.Dynamic binding of data is very easy3.We can easily implement cascading dropdownlistsNote:In method 1 i am sending data from controller using ViewBag.

Note: We can also bind the dropdownlist data using ENUM's and arrays also.But, above are the most reliable and used by many developers (in our company also developers uses this methods only.).Finally i got output like this.

HostForLIFE.eu ASP.NET MVC 5 HostingHostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24x7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality - beyond other hosting control panels - and ease of use, Plesk Control Panel is available only to HostForLIFE's customers. They offer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.

When deploying an ASP.NET MVC 5 application, I wanted to deploy it on Windows Azure to test it. Thanks to Visual Studio, the deployment was really easy but, as soon as I tried to browse the website, I received the following error message:

Could not load file or assembly ‘Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.

This is also one of a few component libraries that are needed for deploying an MVC application:

System.Web.Helpers.dll (required by the web.config)

System.Web.Mvc.dll

System.Web.Razor.dll

System.Web.WebPages.dll

System.Web.WebPages.Razor.dll

Microsoft.Web.Infrastructure.dll

The system libraries are installed with .NET 4, however, 'Microsoft.Web.Infrastructure.dll' is only installed when Visual Studio is installed on the machine. Therefore, short of needing to install MVC and Visual Studio on a production environment, we need to deploy the libraries with out application - and we'd like to do so automatically.

As one possible fix, please try the following: 1. Run the following command in the Package Manager Console. (If you are using Visual Studio, this can be reached via menu options “Tools –> Library Package Manager –> Package Manager Console:)

PM> Install-Package Microsoft.Web.Infrastructure You will see the following messages if it is successfully installed.Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'. Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to Web.

2. You will notice that Microsoft.Web.Infrastructure.dll has now been added as a Reference (can be seen in the references folder of your project in in Solution Explorer) 3. If you look at the properties of this reference you will notice that “Copy Local” has been set to “True” by default. 4. Now when you “Publish ” your project, Microsoft.Web.Infrastructure.dll will be deployed.

About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.