T4MVC Html.ActionLink or Html.RouteLink - how to add target

1.7k views Asked by At

I have a working Html.RouteLink that I want to convert to T4MVC.

The working RouteLink code is as follows:

<%= Html.RouteLink(vaultViewItem.NameDisplay, 
                   new {controller = "Entity", 
                        action= "Index", 
                        dataType = vaultViewItem.VaultID}, 
                   new { target="vaultIFrame"}) %>

Converting the RouteLink directly does not work at all - the resultant URL contains the RouteValueDictionary class name, rather than the individual dictionary items.

I have tried to use the Html.ActionLink with T4MVC and the link will work fine, but the target is never picked up. (Valid link, but sent to _self rather than the stated target.)

<%= Html.ActionLink(vaultViewItem.NameDisplay,
                    MVC.Entity.Index(vaultViewItem.VaultID).AddRouteValues(
                                     new {target = "vaultIFrame"})) %>

How can I display the linked page in the desired iFrame?

1

There are 1 answers

1
David Ebbo On BEST ANSWER

Try this:

<%= Html.ActionLink(vaultViewItem.NameDisplay,
                    MVC.Entity.Index(vaultViewItem.VaultID),
                    new { target = "vaultIFrame" })%>