logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Jay  
#1 Posted : Friday, June 16, 2023 10:23:41 AM(UTC)
Jay

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(...)
Code:
return Redirect(...)

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?

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

judy at Web2Market  
#2 Posted : Tuesday, June 20, 2023 6:15:09 AM(UTC)
judy at Web2Market

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!
shaharyar  
#3 Posted : Wednesday, June 21, 2023 6:57:11 AM(UTC)
shaharyar

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.
Jay  
#4 Posted : Wednesday, June 21, 2023 9:27:56 AM(UTC)
Jay

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?
Joe Payne2  
#5 Posted : Wednesday, June 21, 2023 9:42:32 AM(UTC)
Joe Payne2

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.
Users browsing this topic
Guest
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.