获取 Html.ActionLink 生成多行链接
对于我正在开发的应用程序,我需要让图像标题跨越多行。玩弄一下,我能够从此标记中获得所需的效果:
<a href="http://www.stackoverflow.com">Stack<br>Overflow</a>
为我渲染了这个:
但是我一直无法找到为 HTML.ActionLink 生成链接描述的正确方法,该链接描述将呈现此类输出。
For an application i am working on, I need to have the image captions span multiple lines. Playing around I was able to get the desired effect from this markup:
<a href="http://www.stackoverflow.com">Stack<br>Overflow</a>
rendered this for me:
However I have been unable to find the right way to generate a link description for HTML.ActionLink that will render this kind of output.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 url 不是您网站的一部分,那么使用 HTML 帮助程序生成此链接不会带来太多价值。相反,只需按原样编写即可。如果它是您网站的一部分,并且您可以使用路由来到达地址,您可以编写一个自定义 HTML 帮助程序,默认情况下它不会对链接文本进行 HTML 编码:
在您看来:
If the urls is not part of your web site using an HTML helper to generate this link wouldn't bring much value. Instead simply write it as is. And if it is part of your site and you could use routing to reach the address you could write a custom HTML helper which doesn't HTML encode the link text by default:
and in your view: