What are Url Helpers?

Url helpers allows you to render HTML links and raw URLs. The output of these helpers is dependent on the routing configuration of your ASP.NET MVC application. HTML Element Example Relative URL @Url.Content(“~/Files/asp.netmvc.pdf”) Output: /Files/asp.netmvc.pdf Based on action/controller @Html.ActionLink(“About Us”, “About”, “Home”) Output: <a href=”/Home/About”>About Us</a> @Html.ActionLink(“About Me”, “About”, “Home”,… Continue reading

What are different types of HTML Helpers?

There are three types of HTML helpers as given below: Inline Html Helpers – These are create in the same view by using the Razor @helper tag. These helpers can be reused only on the same view. @helper ListingItems(string[] items) { <ol> @foreach (string item in items) { <li>@item</li> }… Continue reading

Standard Html Helpers

These helpers are used to render the most common types of HTML elements like as HTML text boxes, checkboxes etc. A list of most common standard html helpers is given below: HTML Element Example TextBox @Html.TextBox(“Textbox1”, “val”) Output: <input id=”Textbox1″ name=”Textbox1″ type=”text” value=”val” /> TextArea @Html.TextArea(“Textarea1”, “val”, 5, 15, null)… Continue reading

How to register Custom View Engine in ASP.NET MVC?

To use your custom View Engine, you need to register it by using global.asax.cs file Application_Start() method, so that the framework will use your custom View Engine instead of the default one. protected void Application_Start() { //Register Custom View Engine ViewEngines.Engines.Add(new CustomViewEngine()); //other code is removed for clarity }  

How to make Custom View Engine?

ASP.NET MVC is an open source and highly extensible framework. You can create your own View engine by Implementing IViewEngine interface or by inheriting VirtualPathProviderViewEngine abstract class. public class CustomViewEngine: VirtualPathProviderViewEngine { public CustomViewEngine() { // Define the location of the View and Partial View this.ViewLocationFormats = new string[] {… Continue reading