1. Back To Blog

QuestPond's Interview Questions & Answers on ASP.NET MVC(Model View Controller)

What is the advantage of using HTML helper classes for creating input controls?

In MVC (Model View Controller) we have two options for creating Input controls. Either we can use pure html controls or we can use HTML helper classes which internally generates input controls.

The advantages of using HTML helper classes are: -

  1. Compared to pure html development will be faster with HTML helper classes.

  2. Developer is no more worry about the name of control. It will be automatically handled by HTML helper control.

  3. When controls are generated using HTML helper classes they have the ability to populate there values from the current posted data.

Let's elaborate above point a little.

a. Let's create Customer Model class as follows: -

b. Let say we have a view named MyView of containing a HTML form as follows: -

c. Create SaveCustomer Action as follows.

d. Now create a new strongly typed View called HtmlHelperView of type Customer inside current controller folder as follows

e. Now execute the application and make a request for an action method which will return MyView.

You will notice that CustomerName in the First will be repopulated in the CustomerNametexbox in the seconview.

For technical trainings on various topics like WCF(Windows Communication Foundation), MVC(Model View Controller), Business Intelligence, Design Patterns, WPF, TFS and Basic fundamentals feel free to contact SukeshMarla@Gmail.com or visit www.sukesh-marla.com

For more stuff like this, click here. Subscribe to article updates or follow at twitter @SukeshMarla

Watch our latest video on 25 Important ASP.NET MVC Core interview questions and answers :-

Visit the link for more Step By Step Training Videos on ASP.NET MVC.

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social