I am a little bit confused on something now, i have a view that on the top has a dropdownlist, when the client selects from the list, in javascript i populate 3 textboxes from a database. Below that i have a list of textboxes that the client must fill, when he finishes he clicks on a button that makes some calculations, and i want them to appear in a table in the same page. When everything is done he can click save. So i have 2 submit buttons on the same view, i tried out something that i found from here, but when i press the calculation buttone it refreshes the whole page and removes the previous values. thanks in advance.
2 Answers
Submit buttons will do exactly that - submit the form, meaning the form will be posted to the server and the response will be loaded into the browser.
Instead of submit buttons, use regular buttons - <input type="button"> and attach in JavaScript (jQuery) to the click event.
3 Comments
Oded
@Aris - There are many tutorials and there are answers here on SO on how to use AJAX to call an MVC action.
There are many possibilities. You can do following things.
- Put different submit buttons in different Forms (if it is possible) by using Ajax.BeginForm.
- If you are not able to different button in different forms than please follow this link
- you can also tried Oded solutions.