Reputation: 287
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
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:
Upvotes: 0
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