I have a simple submit input :
@using (Html.BeginForm())
{
<input type="submit" value="Save" id="SaveButton" class="btn" />
}
And now I want to make this button also a hotlink. When I click it, I want to move to "X" Action.
I tried with:
onclick="location.href='@Url.Action("Index", "Student")'"
But it only submits changes, and refresh actual page. Redirect works if input is outside @using(...), but that of course doesn't help me.
What I would do is submit your form using JavaScript:
In your form declaration add a onsubmit event handler
Then the onsunmit javascript function submit the form like this:
If you don't want to do it this way, in your Index Action rather than returning the View do this:
Another way is to redirect to a different Action like so:
Then add another action in your controller called "RedirectAction".
Hope this helps.