Improve company productivity with a Business Account.Sign Up


Razor view syntax question

Posted on 2011-09-22
Medium Priority
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:

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

I want to know why you need to pass the parameter to null, and what it means
Question by:vgruppo
  • 2
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:


Accepted Solution

jagrut_patel earned 1500 total points
ID: 36579488

Expert Comment

ID: 36579505
It calls this overload of ActionLink

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

Author Closing Comment

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article describes and provides a custom-made tool I wrote to give businesses a means of identifying commercial music content, without having to expend too much effort. Business recordings are easily identified from possibly illegal music files …
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

607 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