2

我有以下 Ajax.ActionLink:

                <@Ajax.ActionLink("&nbsp;", "Results",null, new AjaxOptions { UpdateTargetId = "placeholder", InsertionMode = InsertionMode.Replace,HttpMethod = "GET"}, new { @class = "icon-search", id="SearchIcon" })

此链接显示实际字符   . 我怎么能有一个空的 action.link,因为我使用的是基于字体的图标,并且 css 和 html 类将我需要的图像和文本添加到这个链接。

我也刚刚离开了链接 emtpy "" 但它只是打破了页面。

有什么想法吗?

4

4 回答 4

4

如果您希望使用 Unicode 160,更简单的方法是:

@Ajax.ActionLink("\u00A0", "Results", null)
于 2015-05-16T03:10:48.223 回答
1

&nbsp;是 char 160,因此您可以根据需要替换它((char)160).ToString()

@Ajax.ActionLink(((char)160).ToString(), "Results",null, new AjaxOptions { UpdateTargetId = "placeholder", InsertionMode = InsertionMode.Replace,HttpMethod = "GET"}, new { @class = "icon-search", id="SearchIcon" })

当然,你可以在你的 ViewModel 中这样设置:

string LinkText = ((char)160).ToString();

然后做@Ajax.ActionLink(LinkText, "Results", ...

于 2013-10-24T13:08:06.527 回答
1

你可以简单地使用" "like<@Ajax.ActionLink(" ", "Res

于 2013-10-24T13:10:58.737 回答
0

只需使用string.Empty or ""而不是&nbsp设置style:display:block

@Ajax.ActionLink("", "Results",null, new AjaxOptions { UpdateTargetId = "placeholder", InsertionMode = InsertionMode.Replace,HttpMethod = "GET"}, new { @class = "icon-search", id="SearchIcon" })
于 2013-10-24T13:04:21.337 回答