2017-08-11 155 views
0

the doubt is this: I have to use a <a></a>, because of the notation I'm using in all my app, I'm working in ASP.NET MVC. So, I have an href="@Url.Action with class="btn btn-primary", a simple button as this:@ Html.ActionLink到<a href="@Url.Action()>

<a href="@Url.Action("Manage", "Account")" class="btn btn-primary text-right"> 
<span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span> Administrar 
</a> 

(That was an example of the estructure that I need)

But now I have to convert this:

@Html.ActionLink(User.Identity.GetUserName(), "Manage", "Account", 
routeValues: null, htmlAttributes: new { title = "Administrar" }) 

to that estructure. The fact is, I don't know where to put the routevalues and User.Identity.GetUserName(). I don't need the htmlAttributes neither the title.

Please help me and thanks a lot.

回答

0

It should be:

<a href="@Url.Action("Manage", "Account")" class="btn btn-primary text-right"> 
<span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span> 
    @User.Identity.GetUserName() 
</a> 

routevalues will be next parameter in Url.Action method if you need it.

Like this:

Url.Action("Manage", "Account", new { id = 1 }) 
0

For title, you just simple use title="Administrar", so when you hover mouse on the button/link, it'll still show Administrar in tool-tip.

For Username, you will need @ sign at the front.

<a href="@Url.Action("Manage", "Account")" class="btn btn-primary text-right" 
    title="Administrar"> 
    <i class="fa fa-arrow-circle-left" aria-hidden="true"></i> 
    @User.Identity.GetUserName() 
</a> 

Another suggestion is not to use Bootstrap's glyphicon, because they won't be available in next version了。相反,您可能要考虑使用Font Awesome