About return CurrentUmbracoPage() (By Markus Knappen Johansson):
Generally you want to return to the current page if you want to keep
the POST-data that was sent to the controller.
About return RedirectToCurrentUmbracoPage() (By Shannon Deminick.):
If your POST is successful, you shouldn't just return a response, you
should redirect to a page so you can avoid the aweful issue of having
a user press refresh and have it resubmit the POST
In addition to Dennis's post: also consider: return RedirectToCurrentUmbracoUrl(); if you're passing in querystring parameters for your page, these will be preserved.
I want to return model to View back.
I arealdy using return CurrentUmbracoPage();
If using return RedirectToCurrentUmbracoPage(); my model data will be lost.
But I use return CurrentUmbracoPage(); data from model cannot pass to View.
Since you have the form in a partialview, i dont think you can edit the model thatĀ“s beeing passed in and then return it to the currentpage, since your currentpageĀ“s model is not CheckCodeModel, but probobly of type UmbracoTeplatePage or UmbracoViewPage.
Using SurfaceController
I create partial view and using surfacecontroller.
But I want to post model back to View after post function. I can't return model back to view.
My code:
Controller:
View:
Before POST:
Input data
After POST:
After POST data not save. It will reset.
I already use "CurrentUmbracoPage"
Hi Nhan!
Try:
About return CurrentUmbracoPage() (By Markus Knappen Johansson):
About return RedirectToCurrentUmbracoPage() (By Shannon Deminick.):
http://www.enkelmedia.se/blogg/2014/5/8/currentumbracopage-or-redirecttocurrentumbracopage.aspx
Best of luck to you, let me know if it works out for you!
In addition to Dennis's post: also consider:
return RedirectToCurrentUmbracoUrl();
if you're passing in querystring parameters for your page, these will be preserved.Hi Denis.
I want to return model to View back. I arealdy using
return CurrentUmbracoPage();
If usingreturn RedirectToCurrentUmbracoPage();
my model data will be lost.But I use
return CurrentUmbracoPage();
data from model cannot pass to View.Please help me
Since you have the form in a partialview, i dont think you can edit the model thatĀ“s beeing passed in and then return it to the currentpage, since your currentpageĀ“s model is not CheckCodeModel, but probobly of type UmbracoTeplatePage or UmbracoViewPage.
If you where to re-buildthe form to a Ajax formpost you could return the model CheckCodeModel to the same partial view and not having to do a postback. Read more about Ajax formposts with Umbraco here: http://www.systenics.com/blog/creating-an-ajax-enabled-contact-form-in-umbraco-6-with-aspnet-mvc-4-and-twitter-bootstrap/?tag=Umbraco+6
Another way would be to pass the values back to the view in a TempData object instead of ViewBags, since Tempdata objects "survives" the redirect.
Can I do that without partial view?
Write in template page?
Controller:
View:
Thank Denis!
But I want pass ModelState to View, etc.
I will try another solution.
I see. Then look at doing it with Ajax Form, that will work with ModelState.
Good luck to you!
is working on a reply...