This topic will help you understand how to add an ASP.NET MVC control in your application. You will also learn how to add a model, view and controller in an MVC application. When you use MVC Controls in your web application, it reduces the code complexity, increases flexibility, and helps in reusing the code. For more information about working of MVC controls, see MVC Basics.
Complete the following steps to add an MVC Control.
The following image shows how ComboBox control appears after completing the steps above:
Models are required to fetch data for the controls. A model is to be added only where it is required. This example uses Cities.cs
model, and steps have been given to explain how to add model in your MVC application. For more information about Models, see MVC Basics.
Controllers are simple class files. They are responsible for handling incoming requests to the application, retrieve data, and then specify view templates that return a response to the client.
View helps the user to view a visual representation of the model. View is most commonly associated with model and retrieves the data required with the help of controllers. We will add a code in the Index.cshtml
to view ComboBox control in the browser.