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

  • SEARCH
  • Home
  • 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 4243352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:34:01+00:00 2026-05-21T03:34:01+00:00

I have a Partial View with two opposite ActionLinks inside: <div id=divStatus> @if (IsAuthenticated)

  • 0

I have a Partial View with two opposite ActionLinks inside:

    <div id="divStatus>  
    @if (IsAuthenticated) 
        Html.ActionLink("Say Bye", "ProcBye", "Account")
    else 
        Html.ActionLink("Say Hi", "ProcHi", "Account")
    </div>

Each Action link calls a different method on the Controller.

I hear I should use Ajax.BeginForm but I’m still NOT clear how to put this?
My understanding is that I need a <div id="divStatus"> to display the result, but in my case …the result is the Partial View itself.

QUESTION: How do I ensure make it so the Controller just refreshes the calling Partial View??

Shall I just add a div outside the PV?
Shall I add the div inside the PV surrounding the ‘@if (IsAuthenticate)’ call?
Is it better to use Ajax.BeginForm or Ajax.ActionLink in this case?

CODE: What should the code for the Controller look like?

    public ActionResult ProcBye()
    {
        // do something on the server
        // set IsAuthenticated = false;

        return PartialView("_myPV");
    }

There is NO Validation Involved, NO “external” div that needs to be populated, just a simple refresh of the PV independently from what page the PV is located.

Any help will be truly appreciated !!!

  • 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-21T03:34:02+00:00Added an answer on May 21, 2026 at 3:34 am

    Personally I wouldn’t use neither. I would use a separate javascript file in which I would AJAXify the link:

    $(function() {
        $('.mylink').click(function() {
            $('#resultdiv').load(this.href);
            return false;
        });
    });
    

    where resultdiv will be a div which will be update with the partial result returned from the controller action:

    <div id="resultdiv"></div>
    

    You just need to put the mylink class:

    @if (IsAuthenticated) 
    {
        @Html.ActionLink("Say Bye", "ProcBye", "Account", null, new { @class = "mylink" })
    }
    else 
    {
        @Html.ActionLink("Say Hi", "ProcHi", "Account", null, new { @class = "mylink" })
    }
    

    You could also use Ajax.ActionLink if you wanted to:

    @if (IsAuthenticated) 
    {
        @Ajax.ActionLink("Say Bye", "ProcBye", "Account", new AjaxOptions { UpdateTargetId = "resultdiv" })
    }
    else 
    {
        @Ajax.ActionLink("Say Hi", "ProcHi", "Account", new AjaxOptions { UpdateTargetId = "resultdiv" })
    }
    

    Just don’t forget to include the jquery unobtrusive ajax script in this case:

    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two actionlinks on my MVC view like this: <%= Html.ActionLink (click me,Partial1,Temp,new
I have a partial view that needs to get loaded between two div but
I have a partial view that is shared between two controllers and I'm trying
I have a partial view ( Partial.ascx ), two master pages( Master1.Master and Master2.Master
I have two radio button groups in my partial view and based on the
How can I have a view render a partial (user control) from a different
I have a partial view/user control called LogOnUserControl which I display in a side
I am using ASP.Net MVC. I have a partial view which has a form
I want to have two partial views , one for SEARCH and one for
I have a partial view that uses a Telerik MVC Grid, and it has

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.