how to return model back to page after post submit using surfacecontroller v13
hi all,
I have surface controller, partial view form return some values on submit and the controller has some work to do and return model back to page so we can load next stage of the form .
I'm struggling here to send the model back to page bcos return RedirectToCurrentUmbracoPage(); and return CurrentUmbracoPage(); seems to be losing the data . when page reload.
I have assigned model to TempData["CheckerResult"] in controller but struggling to read from View again .
I have tried to convert TempData back to object model it throwing an error.
Have you considered using a script for the form submission?
With an AJAX call, you can submit the data, handle the response, and update the form dynamically.
I like the idea, as I have done this approach in umbraco 7 version . anyway I have manged to work on submit action, and add object into TempData but it seems not possible to read object from view
I have serialized model on surfacecontroller to json and added to TempData and then trying to read it in view using below line
var resultmodel = Newtonsoft.Json.JsonConvert.DeserializeObject<MyContentViewModel>(TempData["mymodeldata"]);
this line return debug error complaining about missing closing bracket. once i remove the line error goes away .
could anyone tell me what s the matter with this line please?
how to return model back to page after post submit using surfacecontroller v13
hi all, I have surface controller, partial view form return some values on submit and the controller has some work to do and return model back to page so we can load next stage of the form .
I'm struggling here to send the model back to page bcos return RedirectToCurrentUmbracoPage(); and return CurrentUmbracoPage(); seems to be losing the data . when page reload.
I have assigned model to TempData["CheckerResult"] in controller but struggling to read from View again . I have tried to convert TempData back to object model it throwing an error.
anyone know how to pass complex models back to view and reload form page?
HI Pathini,
Could you try using
if that doesn't work for you, try using
Cookies, Local Storage or Session State
I'm using surface controller and render partial view using a macro inside richtext editor.
when call submit, post action in controller load more details to model return to current page , I have access TempData from view but seems to be empty
Hi Pathini,
Have you considered using a script for the form submission? With an AJAX call, you can submit the data, handle the response, and update the form dynamically.
Regards
I like the idea, as I have done this approach in umbraco 7 version . anyway I have manged to work on submit action, and add object into TempData but it seems not possible to read object from view
I have serialized model on surfacecontroller to json and added to TempData and then trying to read it in view using below line
this line return debug error complaining about missing closing bracket. once i remove the line error goes away . could anyone tell me what s the matter with this line please?
is working on a reply...