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: -
- Compared to pure html development will be faster with HTML helper classes.
- Developer is no more worry about the name of control. It will be automatically handled by HTML helper control.
- 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
See the following MVC(Model View Controller)video on viewdata, viewbag, tempdata & session:-
Click and see here for more step by step training in ASP.NET MVC