Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 655
Mark Avatar asked May 03 '12 10:05

Mark


People also ask

What is htmlactionlink in MVC with example?

The Html.ActionLink creates an anchor element based on parameters supplied. In this example, we will learn how to use Asp .Net MVC Html.ActionLink. We will also create multiple types of Action links like: HtmlActionLink without controller name. HtmlActionLink with controller name. HtmlActionLink with parameters. HtmlActionLink with Area.

What is Twitter Bootstrap in web development?

What is twitter bootstrap. Twitter Bootstrap is a front end framework to develop web apps and sites fast. In modern web development, there are several components which are required in almost all web projects. Bootstrap provides you with all those basic modules - Grid, Typography, Tables, Forms, Buttons, and Responsiveness.

What is bootstrap in Bootstrap?

Bootstrap provides you with all those basic modules - Grid, Typography, Tables, Forms, Buttons, and Responsiveness. Besides, there are a plethora of other useful front-end components like Dropdowns, Navigation, Modals, Typehead, Pagination, Carousal, Breadcrumb, Tab, Thumbnails, Headers etc.

What is Bootstrap tooltip?

The Bootstrap Tooltip gives us a hint about the specific element in a graphical manner. Tooltip is used for performance reasons so it can be customized as per the requirement domain. Tooltip is implemented using javascript, it relies on a 3rd party library known as popper.js for positioning purposes.


1 Answers

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.

like image 139
Jonathan Wood Avatar answered Oct 02 '22 03:10

Jonathan Wood