http://pabloblamirez.blogspot.com - When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
Ratndeep
Member
313 Points
142 Posts
Two Submit button on one view
Mar 05, 2010 10:36 AM|LINK
Hi All,
I have a view which contain two buttons. I want to call two separate action methods (Using Post ) for these two buttons.
Like when button1 pressed then below action method must be called.
[HttpPost]
public ActionResult Find(Event.SearchArguments searchArguments)
{
}
and on clicking of button2
[HttpPost]
public ActionResult Save(Event.SearchArguments searchArguments)
{
}
How to achieve this.Plz Share your suggestion on this.
<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">
<div id="refHTML"></div>Keep Trying
.
egor598
Contributor
3025 Points
448 Posts
Re: Two Submit button on one view
Mar 05, 2010 11:05 AM|LINK
Hi there,
Ideally you'll have to provide 2 forms with these 2 buttons,with a form action pointing to one of those methods in your controller.
For example on your view you might have something like:
<form method="post" action="/mycontroller/find">
<!-- some html markup here -->
<input type="submit" name="button1" id="button1" value="Search" />
</form>
<form method="post" action="/mycontroller/save">
<!-- some html markup here -->
<input type="submit" name="button2" id="button2" value="Save" />
</form>
If that's not what you require, let me know.
Hope this helps.
ignatandrei
All-Star
134527 Points
21579 Posts
Moderator
MVP
Re: Two Submit button on one view
Mar 05, 2010 11:14 AM|LINK
put a form with default action to Find
for one button use the usual submit
for second button change the action of the form and submit with jquery
Ratndeep
Member
313 Points
142 Posts
Re: Two Submit button on one view
Mar 05, 2010 11:16 AM|LINK
Thanks For reply.
Your solution is correct But in my case i can have only one form so what can be the solution for my problem.
<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">
<div id="refHTML"></div>Keep Trying
.
PaulBlamire
Participant
1272 Points
227 Posts
Re: Two Submit button on one view
Mar 05, 2010 01:28 PM|LINK
Hi there,
Have a looks at this forum post (don't let the title of the post put you off)
http://forums.asp.net/p/1369617/2865166.aspx#2865166
Kind regards,
Paul
Tequila Slam...
Member
3 Points
4 Posts
Re: Two Submit button on one view
Mar 05, 2010 05:35 PM|LINK
Would it work with validationGroup property? Or is this a webform thing?