When submitting one form from view, how can i also read or have controller read data in another form in same page?
+1
A:
You can't. If you have information on the page you want to submit, you must include it with the submitted form. You can use JavaScript to copy the information from one form to the next when submitting, though.
Craig Stuntz
2009-01-20 01:34:49
+4
A:
When you submit a form with a browser, it will only send data for the fields within that <form></form>. This is true regardless of the back-end technology that you use, whether it be ASP.net, MVC.net, PHP, Python, etc.
The only two options I can really think of would be:
- Do like WebForms does and just place a <form> around the entire page, and sort out the results later based on what button is pressed.
- Use Javascript/AJAX to gather any data you like, and push it up any way you like. You could even do some of this in real-time (like when a check box is checked) and not cause a postback of the page.
Of course, there's pros and cons to each, but that's the nature of the beast.
Lusid
2009-01-20 01:42:10
Thanks for your share. it helped me get a handle on how I was going to handle data entry with asp.net mvc
MikeJ
2009-04-14 21:07:42
+2
A:
You could do it on the client-side with a combination of Ajax and Javascript...
<SCRIPT language="JavaScript">
function submitforms()
{
new Ajax.Request(formUrl,
{
parameters: $H({param1:value,param2:value}).toQueryString(),
method: 'post',
onSuccess: function(transport) {
document.myform.submit();
}
}
}
</SCRIPT>
matt_dev
2009-01-20 01:43:04