Currently i have a scaffolded create view that submits to a controller with a regular post. I then have a partial view that submits to a seperate controller via an AJAX post. All of this works very nicely. But now i need to grab the ID from the submit of
the Create view and use that ID inside my AJAX post. Whats the best way to go about this? I can return the ID fine. I had a look at returning a javascript result but couldnt get that to work. Plus i would need to preserve the page somehow.
Is there a way to change the create View to allow me to pass a second model to the Controller on submit? Or do i need to code that all using AJAX?
If i was to post all the values to a controller using AJAX, how would i go about using the DataAnnotations (particularly the clientside stuff)
alm1
Member
133 Points
60 Posts
Posting data with returned ID from controller
Feb 26, 2012 11:57 PM|LINK
Hi All
Currently i have a scaffolded create view that submits to a controller with a regular post. I then have a partial view that submits to a seperate controller via an AJAX post. All of this works very nicely. But now i need to grab the ID from the submit of the Create view and use that ID inside my AJAX post. Whats the best way to go about this? I can return the ID fine. I had a look at returning a javascript result but couldnt get that to work. Plus i would need to preserve the page somehow.
Is there a way to change the create View to allow me to pass a second model to the Controller on submit? Or do i need to code that all using AJAX?
If i was to post all the values to a controller using AJAX, how would i go about using the DataAnnotations (particularly the clientside stuff)
Thanks
Andy