在ASP.net MVC Razor中渲染包含span的链接? [英] Render link containing span in ASP.net MVC Razor?

查看:97
本文介绍了在ASP.net MVC Razor中渲染包含span的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  @ Html.ActionLink(关于本网站,关于)

但是如何以剃刀语法编写以下内容:

 < a> 
< span>您好,我很不方便!< / span>
< / a>

欣赏正确方向上的任何一点:)

解决方案

我不确定我是否正确地遵循了您的示例,因为它没有包含链接,链接文本与跨度文本不同,但是应该给出你有个大概的想法:

 < a href ='@ Url.Action(About)'> 
< span>您好,我很不方便!< / span>
< / a>

使用 Url.Action()将会返回实际的超链接而不是元素。


Rendering a simple link is easy:

@Html.ActionLink("About this Website", "About")

But how would you write the following in razor syntax:

<a>
    <span>Hello, I'm inconvenient!</span>
</a>

Appreciate any point in the right direction :)

解决方案

I'm not sure I follow your example properly as it doesn't contain a link and the text for the link is different to that of the span but something like this should give you a general idea:

<a href='@Url.Action("About")'>
    <span>Hello, I'm inconvenient!</span>
</a>

Using Url.Action() will return the actual hyperlink rather than the element.

这篇关于在ASP.net MVC Razor中渲染包含span的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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