Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action link to the same page

I need to create an html action link that is equalivent to

 <a href="#">Test Link</a>

or an action link to the current page. Anyone have any examples?

like image 909
RiceRiceBaby Avatar asked May 23 '13 15:05

RiceRiceBaby


People also ask

What is a URL action?

A URL action is a hyperlink that points to a web page, file, or other web-based resource outside of Tableau. You can use URL actions to create an email or link to additional information about your data. To customize links based on your data, you can automatically enter field values as parameters in URLs.

What is difference between HTML ActionLink and URL action?

There is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.

How do you add a link in Cshtml?

Use @Html. ActionLink("Menus", "Menu", "yourController", null, new { @class = "page-scroll" }) and add a controller method named Menu that return the view.


2 Answers

You can try with this:

<a href="@Url.Action(null)">Test Link</a>

The helper Url.Action with the first parameter in null, return the current action.

Update for @MichaelLeanos's comment

For MVC6:

<a href="@Url.Action()">Test Link</a>
like image 171
andres descalzo Avatar answered Oct 05 '22 15:10

andres descalzo


Yes, I have a suggestion. Just put <a href="#">Test Link</a> in your view. The only reason to use Html.ActionLink is to resolve a URL dynamically. Here there's no need, so just use the HTML.

like image 20
Chris Pratt Avatar answered Oct 05 '22 13:10

Chris Pratt