T4MVC Html.ActionLink or Html.RouteLink - how to a

2019-05-11 04:34发布

问题:

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:

Try this:

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


标签: t4mvc