0

How to use Input button for @Html.ActionLink?

In my cshtml I have this code:

<div>
  @Html.ActionLink("Back to menu", "HomeController")
</div>

Now I whant to use instead hyperlink button (Back to menu), input submit button, so this button:

<input class="btn" type="submit" value="Back to menu">

Thanks.

tereško
  • 58,060
  • 25
  • 98
  • 150
Daniel K Rudolf_mag
  • 287
  • 2
  • 5
  • 18

3 Answers3

2

You can't - you can use css so the link will look like button, or you can utilize Url.Action and javascript instead. I.E.:

<input class="btn" type="submit" value="Back to menu" onclick="window.location='@Url.Action("Index", "Home")';return false" />
Ondrej Svejdar
  • 21,349
  • 5
  • 54
  • 89
0

Ok, I solved it, Ondrej Svejdar thanks for advice, I use javascript and works fine:

<input class="someCss" type="button" value="Back to Edit Menu" onclick="Redirect()"/>

And under button I use this javascript:

<script type="text/javascript">
    function Redirect() {
        var url = "@Url.Action("Registration")";
        location.href = url;
    }
</script>

So result is:

enter image description here

Daniel K Rudolf_mag
  • 287
  • 2
  • 5
  • 18
0

<input type="button" value="Button" />

value="button" />

Manish
  • 1
  • 1
  • Doesn't provide a solution for the problem at hand. –  Jan 27 '15 at 08:12
  • 1
    Code blocks on their own are not usually useful answers. Please explain what the code you're showing does, and why/how that code answers the question. – Lea Cohen Jan 27 '15 at 08:17