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 7757823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:11:38+00:00 2026-06-01T13:11:38+00:00

In the following ActionLink id like to set PartyId & IsFollowing with two jQuery

  • 0

In the following ActionLink id like to set PartyId & IsFollowing with two jQuery vars

@Ajax.ImageActionLink("ToggleEnabled", "Following Status",
                                    new { id = PartyId },
                                    new AjaxOptions
                                    {
                                        UpdateTargetId = "ti" + PartyId,
                                        InsertionMode = InsertionMode.Replace,
                                    },
                                    IsFollowing,
                                    "../../Images/tick.png",
                                    "../../Images/tick_grey.png",
                                    PartyId)

How can I do this?

  • 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-06-01T13:11:39+00:00Added an answer on June 1, 2026 at 1:11 pm

    My Solution

    As this cant be done the way I wanted, here is a jQuery version for completeness : This will toggle an image if clicked, update the DB via $.Ajax & change image to toggled version

    HTML

    <a id="HD_FollowingLink">
      <img id="HD_FollowingImage" />
    </a>
    

    jQuery & JavaScript

    $('#HD_FollowingLink').click(function () {
            // 'Following' Toggle Button has been clicked, get its 'id' & use ajax to toggle DB, display ajax returned data.IsFollowing (which should be toggled)
            var id = $(this).attr('id');              
            $.ajax({
                url: "/Home/ToggleEnabled/" + id,
                type: "POST",
                data: ({ id: id }),
                success: function (data, textStatus) {
                    ToggleFollow(data.IsFollowing, id);
                }
            }); //$.ajax end
        });
    
    function ToggleFollow(IsFollowing, id) {
    // Called by LoadHoverDivData & HD_FollowingLink $.Ajax calls
    $('#HD_FollowingLink').attr("id", id); //Set this id so we can use it in     
    $('#HD_FollowingLink').click handler
    
    
    if (IsFollowing == true) {
    $('#HD_FollowingImage').attr("src", "../../Images/tick.png");
    
    } else {
    $('#HD_FollowingImage').attr("src", "../../Images/tick_grey.png");
    }
    };
    

    MVC Action

    public ActionResult ToggleEnabled(int id)
    {
    if (Request.IsAjaxRequest())
    {
    // Get if party being followed 
    int PID = ViewBag.ThisParty.PartyId;
    var f = db.Followings.SingleOrDefault(q => q.PartyFollowedID== id && q.ThisPartyId == PID);
    f.following = f.following != true;// Toggle bit
    db.Entry(f).State = System.Data.EntityState.Modified;
    db.SaveChanges();// Save toggled bit back to DB
    
    return Json(new {IsFollowing = f.following });
    }
    return Content("Error");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following ajax ActionLink method. @Ajax.ActionLink( , RemovePerson, General, new { PersonId
I have the following @Html.ActionLink(Edit, EditProg, new { id = item.ID }) I like
The following ActionLink: <%= Html.ActionLink(Home £, Index)%> Generates the markup: <a href=/>Home &#194;&#163;</a> Which
I am having following action link: <%= Html.ActionLink(Check this, Edit, test, new { id
I am using the following: <img src=../../Content/Images/lock_16.gif /> @Html.ActionLink(Register, Register, Users, null, new {
I have the following: @Html.ActionLink(Register, Register, Users) I would like to make the link
I am in the process of learning MVC3 and I have the following @Ajax.Actionlink
I would like to use custom @Html.ActionLink I am trying to use the following
I have the following Html: <%: Html.ActionLink(item.ProductName, Details, Product, new { item.ProductId }, null)%>
I am using MVC3 Jquery and AJAX to produce something like List/Details view. Now

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.