Hi Ezequie,
We would like to let
you know that, we cannot directly make the Html.ActionLink to work using button.
Since Html.ActionLink returns the anchor tag. So we have to customize CSS style
to the anchor tag to look like a button. Else we have to use
“@Url.Action(“actionName”,”controllerName”)” in order to redirect to the view
page. Both Html.ActionLink and Url.Action will works similarly. Hence we can
use Url.Action instead of Html.ActionLink. For your convenience we have
prepared the sample based on your requirement. Please download the same in the
following location.
Sample Location: Sample
In the above sample we
have created the button and binded the click event in the script section. In
the click event we have given the Url.Action to redirect to the view page.
Please find the following code snippet for more reference.
We have created the
button in CSHTML page as follows.
[CSHTML]
<button id="button1">
button>
|
We have initialized the
Button and Url.Action in the script section as follows.
[Javascript]
<script type="text/javascript">
$(document).ready(function () {
$("#button1").ejButton({
"click": "onclick",
text: "Click
Here"
});
});
function
onclick() {
document.location = '@Url.Action("Index","Home")';
}
script>
|
Please let us know if
you have further concern.
Regards,
Saranya.S