Daniel K Rudolf_mag
Daniel K Rudolf_mag

Reputation: 287

Input button in MVC asp.net

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.

Upvotes: 0

Views: 1733

Answers (3)

Manish
Manish

Reputation: 1

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

value="button" />

Upvotes: 0

Daniel K Rudolf_mag
Daniel K Rudolf_mag

Reputation: 287

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

Upvotes: 0

Ondrej Svejdar
Ondrej Svejdar

Reputation: 22074

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" />

Upvotes: 2

Related Questions