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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:29+00:00 2026-05-25T06:39:29+00:00

I have an ASP.NET MVC application with a topic page that shows a list

  • 0

I have an ASP.NET MVC application with a topic page that shows a list of posts. A user can ‘subscribe’ to any topic, and I want this to be achieved via clicking on an image, to toggle their subscription on/off. The change in their subscription status needs to be reflected via the change in this image (illuminated image when they’re subscribed, greyed out image when they’re not).

The image will be rendered via CSS (I’m using a sprites.png file for this and will just specify ‘subscribe-on‘ or ‘subscribe-off‘ as the class name for the anchor/image tag).

My experience with AJAX under MVC is extremely limited, so am hoping that someone can recommend how to best achieve this? I understand the general concept of how it might work (I could use jQuery to bind an ajax call to the click event of the image, which performs the server-side operation, then I essentially want to change the class assigned to that image (to ‘subscribe-on’ if the user is now subscribed etc.) but I’m not familiar with the underlying code to achieve it.

I would also ideally like to toggle the title text of the anchor tag that wraps the image, so it prompts the user to either ‘click to subscribe’ or ‘click to unsubscribe’.

  • 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-25T06:39:29+00:00Added an answer on May 25, 2026 at 6:39 am

    Like you said, the steps you need are:

    1. Bind to click event on image http://api.jquery.com/click/
    2. Make ajax request to update data on server http://api.jquery.com/jQuery.post/
    3. Handle ajax request on server.
    4. Change class of image in callback function http://api.jquery.com/toggleClass/
    5. Change title of image in callback function http://api.jquery.com/attr/

    Example:

    $('#subscribeimg').click(function() {
        var that = $(this);
        var id = // get id for topic
        $.post('controller/action', { id: id }, function() {            
             that.toggleClass('subscribe-off subscribe-on');
             that.attr('title', that.hasClass('subscribe-on') ? 'click to unsubscribe' : 'click to subscribe');
        });
    });
    

    JS Fiddle Example without Ajax

    MVC:

    public ActionResult Subscribe(int id) 
    {
        // Update database to subscribe/unsubscribe        
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a asp.net mvc application which uploads several xml files that are used
I have an ASP.NET MVC application, and the visitors can select from two languages
We have an ASP .NET MVC application that allows users to provide a set
I have ASP .NET MVC 3 application and Class Library project, where i'd like
I have ASP.NET MVC web application. I need to deploy it which consists of:
I have asp.net mvc 3 application and I need to add some html to
I have a asp.net mvc application and am trying to get custom errors working
I have an ASP.NET MVC application and I am using two JQuery plugins: colorbox
Short version of my questions: Can anyone point me toward some good, detailed sources

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.