First I tried with
<input type="button" value="Something" onclick="location.href='@Url.Action("ActionName")'" />
But this is a button and I want just a link. I've seen somewhere (while wildly browsing the programming forums) a way to hide a button link behind an anchor, but couldn't find/make it.
Then I tried with
<a href="@Html.ActionLink("Something", "ActionName", "ControllerName")"></a>
(here, actually, on the page, the link looked like Something">, whereas the " and > shouldn't be there)
and also
<a href="@Url.Action("ActionName", "ControllerName")">Something</a>
but the latter 2 ways (with the anchor tag) don't work, by means, I don't get directed to the other page. So, any suggestions about how to hide a button behind a link, or how to make the anchor tags run ?
You want an anchor, but the suggested code doesn't work. Try this way (it worked for me):
<a onclick="location.href='@Url.Action("ActionName")'">Something</a><br />
It will work this way, but you will not have the hand, when you hover the link. So just add href="#"
, like that:
<a href="#" onclick="location.href='@Url.Action("ActionName")'">Something</a><br />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With