问题描述
是否有可能使用Ajax.ActionLink方法与HtmlString作为链接文本,而不是一个字符串?
Is it possible to use an Ajax.ActionLink method with an HtmlString as the link text and not a string?
这样做的原因是,我想要做的事,像这样:
The reason for this is that I want to do something like so:
@Ajax.ActionLink("<span style='highlight'>Hello</span> World", ...)
如果我试试这个,现在,它会返回跨度等。我的网页上。所以,我需要把它恢复为HtmlString
If I try this now, it'll return the span etc.. on my page. So I need to return it as a HtmlString
编辑:
刚试过:
public static MvcHtmlString ActionLink(
this AjaxHelper ajaxHelper,
IHtmlString linkText,
string actionName,
Object routeValues,
AjaxOptions ajaxOptions
)
{
return ActionLink(ajaxHelper, linkText, actionName, routeValues, ajaxOptions);
}
和我有一个堆栈溢出异常?
And I got a stack overflow exception?
推荐答案
我解决它用在这里找到了解决办法:<一href=\"http://forums.asp.net/p/1702210/4518688.aspx/1?Re+Quick+question+about+Ajax+ActionLink+and+span\" rel=\"nofollow\">http://forums.asp.net/p/1702210/4518688.aspx/1?Re+Quick+question+about+Ajax+ActionLink+and+span
I solved it by using the solution found here: http://forums.asp.net/p/1702210/4518688.aspx/1?Re+Quick+question+about+Ajax+ActionLink+and+span
这篇关于ASP.NET MVC - Ajax.ActionLink与HtmlString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!