是有可能使用含有的元素的ActionLink的? [英] Is it possible to use an ActionLink containing an element?

查看:422
本文介绍了是有可能使用含有的元素的ActionLink的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这个问题说,是否有可能使用含有一种元素的ActionLink的,如果没有,什么是实现这一目标的最佳途径?

As the question says, Is it possible to use an ActionLink containing an element, and if not, what is the best way to achieve it?

举例来说,可以说我有一个跨度元素,我想整个事情是一个超链接...以下工作:

For example, lets say I have a Span element, I want the whole thing to be a hyperlink... The following works:

<a href="/Site/Page/@Model.ID?Type=test">
                <span class="box5">Click anywhere in this box</span> </a>

想象一下,跨度/ CSS类box5使这个大......原本是一个DIV,但是,我发现,没有按照标准,这似乎遵循ok了。

Imagine that span/css class box5 makes this large... Was originally a DIV, but, I found that didn't follow standards and this appears to follow ok.

这使得和工作正常,但,反正是有使用ActionLink的呢?我试图去猜测语法,如(复制从形式):

This renders and works fine, but, is there anyway to use an ActionLink instead? I have tried to guess the syntax such as (copying from forms):

@using (Html.Actionlink){<span class="box5">Click anywhere in this box</span>}

和许多其他的组合没有任何的运气。

and many other combinations without any luck.

现在,我的手动HTML解决办法正常工作,我很高兴离开它,但它是可以使用MVC ActionLink的,如果是,我应该甚至担心/会有什么好处?

Now, my manual HTML workaround works fine and I am happy to leave it, but, is it possible to use a MVC ActionLink, and if it is, should I even worry/would there be any benefits?

推荐答案

只需使用的 @ Url.Action 来代替:

<a href="@Url.Action("Page","Site", new { id = Model.Id, @Type = "test" })">
 <span class="box5">Click anywhere in this box</span> </a>

这篇关于是有可能使用含有的元素的ActionLink的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆