Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Razor view syntax question

Posted on 2011-09-22
4
Medium Priority
?
547 Views
Last Modified: 2012-05-12
The following syntax Razor View I


@ Html.ActionLink (item.Name, "Detail", "Restaurant", new {id = item.ID})

which implies the generation of the following link wrong:
http://localhost:49237/restaurant/Detail?Length=10

If I add a null parameter as follows
@ Html.ActionLink (item.Name, "Detail", "Restaurant", new {id = item.ID}, null)
the link is correct
http://localhost:49237/Restaurant/Detail/2


I want to know why you need to pass the parameter to null, and what it means
thanks
0
Comment
Question by:vgruppo
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36579433
public static string ActionLink(this HtmlHelper htmlHelper,  string linkText,  string actionName,                                string controllerName, object values, object htmlAttributes)

The parameter you meant is htmlattributes where as it used to pass any HTML attribute to the action link.

Please refer: http://stackoverflow.com/questions/7329041/how-to-merge-htmlattributes-for-html-actionlink-mvc3

0
 
LVL 8

Accepted Solution

by:
jagrut_patel earned 1500 total points
ID: 36579488
0
 
LVL 8

Expert Comment

by:jagrut_patel
ID: 36579505
It calls this overload of ActionLink

http://msdn.microsoft.com/en-us/library/dd492124.aspx

By passing null value for 5th argument we make it invoke following overloaded method

http://msdn.microsoft.com/en-us/library/dd504972.aspx
0
 

Author Closing Comment

by:vgruppo
ID: 36579621
I would have preferred an explanation of the behavior of the function with 4 parameters and a few more example.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question