0

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 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

the problem is that i need some calculations to be done, so how can i trigger a controller actionresult or something like that, so the calculations can be done and displayed.
@Aris - There are many tutorials and there are answers here on SO on how to use AJAX to call an MVC action.
how will i declare the controller method?
0

There are many possibilities. You can do following things.

  1. Put different submit buttons in different Forms (if it is possible) by using Ajax.BeginForm.
  2. If you are not able to different button in different forms than please follow this link
  3. you can also tried Oded solutions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.