简体   繁体   中英

Adding   to an Ajax.ActionLink

I have the following Ajax.ActionLink:

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

This link shows the actual charachters & nbsp ; . How can I have an empty action.link, as I'm using font based Icons, and the css and html class add the image and text I need to this link.

I've also just left the link emtpy "" but it just breaks the page.

Any thoughts?

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

@Ajax.ActionLink("\u00A0", "Results", null)

&nbsp; is char 160, so you can replace it with ((char)160).ToString() if you like.

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

Of course, you could set this up in your ViewModel with something like:

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

And then do @Ajax.ActionLink(LinkText, "Results", ...

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

只需使用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" })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM