I am building a webapp using ASP.NET MVC. In my application I need to change the functionality of a submit button in HTML code. Right now after clicking submit, the data is submitted and the page redirect to some particular one (I don’t know why this one) but I want to stay at the same page. How can I achieve this? I have done research but all the answers didn’t work for me.
The code of the button is following:
JavaScript
x
2
1
<button type="submit" value="Dodaj" class="btn btn-success" data-toggle="modal" data-target="#infoModal">Dodaj</button>
2
Advertisement
Answer
JavaScript
1
10
10
1
@using (Html.BeginForm()) {
2
3
<input name="Save" type="submit" value="Save" />
4
}
5
6
@using (Html.BeginForm("MyController", "MyAction")) {
7
8
<input name="Save" type="submit" value="Save" />
9
}
10
You can set manually the redirection
The first one submits to the same action and same view is rendered
or
Inside the controller, there may be a code to redirect to some other action