Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

asp.net - Display html within @html.actionlink with Twitter Bootstrap

I'm using Twitter Bootstrap, and trying to make my links ASP.Net MVC look nice.

However, the <i class=... in the link below, is html encoded, rather than being sent as html to the browser:

    @Html.ActionLink("<i class='icon-user icon-white'></i> Create New", "Create", "", New With {Key .class="btn btn-primary"} )

How button appers

Is there any way of keeping the <i class=... as html, so that the button displays correctly?

question from:https://stackoverflow.com/questions/10429510/display-html-within-html-actionlink-with-twitter-bootstrap

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of using @Html.ActionLink(), just write out the <a> tag yourself. You can use @Url.Action() to get the URL of an action for your HREF attribute.

The @Html helpers are nice, but they won't always provide the flexibility you need.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...