Reputation: 9062
I am trying to write my own LightWeight MVC for .Net 2.0 using NHaml as the view engine.
In ASP.Net 3.5 MVC the View file we used to specify the link by the 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)
There are more similar static classes like FormExtensions
, InputExtensions
etc.
How does ASP.Net MVC handle it? Does it generates dynamic code for Html.ActionLink?
Upvotes: 3
Views: 1332
Reputation: 4662
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.
Upvotes: 5