AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Reload entire page from within partial view controller code
Rank: Member
Groups: Authorized User, Developers Joined: 11/12/2018(UTC) Posts: 25
Thanks: 1 times Was thanked: 4 time(s) in 3 post(s)
|
This seems like it should be simple, but I can't seem to find an answer. Maybe my Google skills just aren't up to par. Under certain circumstances, I would like the controller's POST code for a partial view to just reload the whole webpage. I've tried things like: Code:return RedirectToAction(...)
Code:return RedirectToRout(...)
They all just draw another copy of the page (or most of it) where the partial view is located, which is what I expected would happen. What code do I need to reload the entire page?
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
Jay, Don't feel bad, I haven't mastered this yet myself. I think this is the hardest part of MVC for me!
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Hi Jay, Quote:I would like the controller's POST code for a partial view to just reload the whole webpage This isn't quite clear what you want to achieve. Please explain a bit more so that we could be able to help you. Normally when we are using Ajax call and playing with partial views, to reload the entire page on our storefront side we usually use the JavascriptRedirect function. You will be able to see the references in CheckoutController.
|
|
|
|
Rank: Member
Groups: Authorized User, Developers Joined: 11/12/2018(UTC) Posts: 25
Thanks: 1 times Was thanked: 4 time(s) in 3 post(s)
|
My partial view has a button: Code:<input class="btn" type="submit" id="myButton" name="myButton" style="background-color: #206BA8; color: #FFF" value="Do Something" />
My controller code is like this: Code:[HttpPost]
[ProtectFromBots]
public ActionResult _MyPartialView(List<SomeModel> model)
{
// process various things
// Here I would like to reload the entire page that this partial view is on in the browser, just like if you were on a different page and clicked a link to go to this page.
}
I tried using JavaScriptRedirect: Code:[HttpPost]
[ProtectFromBots]
public ActionResult _MyPartialView(List<SomeModel> model)
{
// process various things
return JavaScriptRedirect(samePageUrl)
}
and I get the same result I mentioned above - the page is displayed a second time within the existing page where this partial view was displayed before. If I can't reload the page from the partial view's code, is there a way to force all the other partial views and the main view to render again using any updated data?
|
|
|
|
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
The question is your submit button. Is it submitting an ajax form? If so, you can add a OnSuccess="yourjs()" callback to the form declaration in the ajax options. Then change your controller to return Content(""); Essentially nothing since you're not returning a result anyways.
<script> function yourjs() { window.location.ref = '/somepage'; }
Or if you want to force the entire current page to reload, change it to: window.location.reload();
So clicking the button submits the form to the controller via AJAX. Upon completion, your javascript is called which immediately does a redirect or reload.
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Reload entire page from within partial view controller code
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close