Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4125746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:54:36+00:00 2026-05-20T23:54:36+00:00

My site has a concept like Skype that allow users to go "Online" and

  • 0

My site has a concept like Skype that allow users to go "Online" and "Offline". I created a partial view that allows the user to switch mode:

@if (Convert.ToBoolean(ViewData["IsLogged"].ToString()))
{
<div id="onlineStatus">
    You are currently <strong>ONLINE</strong> >>
    @Html.ActionLink("Go OFFLINE", "GoOffline", "Account")
</div>
}
else
{
<div id="offlineStatus">
    Ready for business >>
    @Html.ActionLink("Go ONLINE", "GoOnline", "Account")
</div>           
}

This is how we load the Partial View:

public ActionResult OnlineStatusCtrl()
{
     if (SiteUser.IsAuthenticated)
        ViewData["IsLogged"] = SiteUser.IsOnline.ToString();

      return PartialView("OnlineStatusCtrl");
}

When a user clicks on the link "Go ONLINE" or "Go OFFLINE", the Controller respond as:

public ActionResult GoOnline()
{
    if (SiteUser.IsAuthenticated)
        SiteUser.GoOnline();

    ViewData["IsLogged"] = "True";

    return RedirectToAction("Index", "Home");
    //return PartialView("OnlineStatusCtrl");
    //return EmptyResult();
}

public ActionResult GoOffline()
{
    if (SiteUser.IsAuthenticated)
        SiteUser.GoOffline(true);

    ViewData["IsLogged"] = "False";
    
    return RedirectToAction("Index", "Home");
}

This works well …but the ONLY problem is that if I am on View XXXX, and I click on "Go Online", the controller redirects me to the Index View.

I tried "return EmptyResult()" or "return PartialView("OnlineStatusCtrl") but it does just not work.

From the code, you can see that the only thing the PartialView cares about is the "ViewData[‘IsLogged’] value"

QUESTION:
What is the way to REFRESH a partial view without having to refresh the entire page or redirect to the main page?

Is it maybe a matter of putting an Html.Beginform() ?
Is it maybe a matter of the Controller returning something that just refresh the content of the PartialView independently from what view is holding the PV itself?

Aiaiaiaia
I still can’t figure out how MVC works with PartialViews/


UPDATE
I have updated the code as x suggested and the HTML output is as follow:

<div id="divStatus">
    <form action="/" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#divStatus" id="form0" method="post">        
        <div id="offlineStatus">
            Ready for business >>
            <a href="/Account/GoOnline">Go Online</a>
        </div>
   </form>
</div>

When I click on the LINK, the Controller return PartialView("_OnlineStatusCtrl"); which is hte name of the calling PV …and the ENTIRE PAGE gets replaced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:54:36+00:00Added an answer on May 20, 2026 at 11:54 pm

    You’re going to have to use an ajax call of some sort (Microsoft ajax helpers built into MVC, or jquery/javascript ajax call.

    To use Microsoft’s Ajax, you can use Ajax.BeginForm or Ajax.ActionLink. Both take an AjaxOptions parameter that will allow you to set javascript functions for OnSuccess, and an UpdateTargetId to display the returned data (usually a partial view). Using this will call your action which should return a partial view. Your partial view then replaces the html element (usually a div) identified by the UpdateTargetId parameter. If you decide to go this route, make sure you reference all the proper Microsoft ajax/mvc scripts. You’ll pretty much need each script with any combinations of Microsoft, Ajax, Mvc, and even unobtrusive in the name.

    Here’s an example of one of my ajax forms (modified slightly for simplicity)

        <% using(Ajax.BeginForm("addAttribute", new { id = Model.PersonId, attributeId = item.AttributeId }, new AjaxOptions { UpdateTargetId = "myTargetId", OnSuccess = "initForm" })) { %>
            <input type="submit" value="Ok" class="editMode okButton" disabled="disabled" />
            <input type="button" class="editMode cancelButton" value="Cancel" />
            <br />
            <input type="button" value="Add" class="addButton" />
        <% } %>
    

    I have a div with an id of “myTargetId” (for this example) that will be updated with the returned partial view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The site I'm building allows users to create posts and has a Twitter-like concept
I have a site that gets most of it's traffic (like 90%) from users
My site has an input box, which has a onkeydown event that merely alerts
My site has several listing pages and on each page, I'd like to enable
My site has few global configurations. For example "smtp-server address", "company address", etc. Of
My PHP site has header,body,footer files that are included into the INDEX.PHP page. On
The site I am working on has the concept of a User and a
I'm building a site that offers functionality to users without requiring them to register.
The site I am developing has a large amount of javascript that is shared
My site has a few pages that point to the same child page. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.