Building an Action Link to another Area

Crystal Rouse
Crystal Rouse used Ask the Experts™
on
I"m trying to build an Action Link to another Area.  The link I have is:

 @Html.ActionLink(Model[i].ID, "Details", "Orders", new { Area = "Order" }, new { id = Model[i].ID }, new
                       {
                           @target = "_blank"
                       })

Open in new window


I"m getting errors. Is this the correct way to build an Action Link to another Area?  The Link works correctly within the Order Area.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Commented:
That's mostly correct. Your fourth parameter dictates any route parameters (e.g. area name) that should be evaluated when materializing the appropriate URL from a route definition. I believe your last two parameters are in error, though. The last parameter should be an object whose properties contain the names and values of any HTML attributes you want to include on the generated <a> tag. You've passed two different objects as two different parameters; these should just be one object with two properties:

@Html.ActionLink(Model[i].ID, "Details", "Orders", new { Area = "Order" }, new { id = Model[i].ID, @target = "_blank" })

Open in new window

Crystal RouseTask Lead

Author

Commented:
Thanks! That worked!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial