tags:

views:

259

answers:

2

I am trying to write my own LightWeight MVC for .Net 2.0 using NHaml as view Engine.

In ASP.Net 3.5 MVC, In View file we used to specify link by code snippet.

Html.ActionLink("Add Product","Add");

In MVC Binary, there is no function to match this call. I Only found,

(In class System.Web.Mvc.Html.LinkExtensions )

public static string ActionLink(this System.Web.Mvc.HtmlHelper htmlHelper, 
   string linkText, string actionName)

and there are more similar static classes like FormExtensions, InputExtensions etc.

How ASP.Net Mvc handles it , it generates dynamic code for Html.ActionLink ?

A: 

Have you checked out the code on Codeplex? The MVC Framwork is open source, so you can dig around as much as you need to.

Kieron
+1  A: 

The ActionLink method is an extension method (hence the this before the type of the first parameter). This means you can use this method as an instance method on all HtmlHelper instances, even though it is not defined on HtmlHelper.

Html is a property on the View of type HtmlHelper. This means you can use the ActionLink extensionmethod on it.

The ActionLink method itself does nothing more than generate a link string (with regards to its arguments) and return that string.

Inferis