Asp.Net MVC ActionLink


Asp.Net MVC ActionLink



Can anyone explain why the following happens? And how to resolve, Visual Studio 2010 and MVC2

<%= Html.ActionLink("Add New Option", "AddOption", "Product", new { @class = "lighbox" }, null)%> 

Results in

/Product/AddOption?class=lightbox

<%= Html.ActionLink("Add New Option", "AddOption", "Product", new { @class = "lighbox" })%> 

Results in

/Product/AddOption?Length=7

Thanks


Replicate Memcached to multiple servers

1:

ASP.NET MVC Dynamically set CSS Class to list item based on route
You're using these respective overloads:. Not display/write specific html if model.entity is null
public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, Object routeValues, Object htmlAttrialthough es ) 
From: http://msdn.microsoft.com/en-us/library/dd504972.aspx. Possible to disable/make item not visable in select list?
public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, Object routeValues, Object htmlAttrialthough es ) 
From: http://msdn.microsoft.com/en-us/library/dd492124.aspx. Is MVC .net right for my project type? The first new { @class = "lighbox" } is passed as the routeValues argument when it should be the htmlAttrialthough es argument.. Last login time using the ASP.NET Membership API This sort of problem is common with the extension methods used in MVC. Weird ASP.NET MVC links with (A(anythingworkshere))In must any times guidance to use named arguments (C# 4.0) to make things more readable:. What are some alternatives to RedirectToAction?
<%= Html.ActionLink(linkText: "Add New Option",     actionName: "AddOption",    controllerName: "Product",     htmlAttrialthough es: new { @class = "lighbox" },     routeValues: null)%> 

2:

This is an case of "overload hell" in ASP.NET MVC.. The first code calls the following method:.
public static MvcHtmlString ActionLink(     this HtmlHelper htmlHelper,     string linkText,     string actionName,     string controllerName,     Object routeValues,     Object htmlAttrialthough es ) 
whereas the second code calls this one:.
public static MvcHtmlString ActionLink(     this HtmlHelper htmlHelper,     string linkText,     string actionName,     Object routeValues,     Object htmlAttrialthough es ) 
Notice this the string parameter controllerName in the first call is becoming routeValues in the second one. The string value "Product" is being passed to the routed values: the string property Length is used, which has a length of 7 here, hence the "Length=7" you're receive ting in the route.. Considering the first method, it seems this you've swapped the routeValues and htmlAttrialthough es parameters..


97 out of 100 based on 87 user ratings 1087 reviews

@