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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:30:59+00:00 2026-05-15T08:30:59+00:00

I am playing around with AJAX functionality using ASP.NET MVC. I have created a

  • 0

I am playing around with AJAX functionality using ASP.NET MVC. I have created a page with a menu of categories generated from a database which when clicked makes an AJAX request to a Controller and then a Controller returns a PartialView.

<% foreach (var item in Model.Categories)
{ %>
    <li>
        <%= Ajax.ActionLink(item.CategoryName,
                                "Index", "Home",
                                new { id = item.CategoryID },
                                new AjaxOptions { UpdateTargetId = "gallery" })%>
    </li>
<% } %>


[HttpPost]
    public ActionResult Index(int id)
    {

        List<Image> images = imageRepository.getCategoryImages(id).ToList();

        return PartialView("gallery", images);
    }

The gallery div contains a number of images, on first load it has every image which is stored in a database. I have used lightbox a JQuery plugin so when an Thumbnail is click it enlarges and a user can click through the images. When the partial view is returned the lightbox event handler is no longer bound.

$(function () {
        $('#gallery a').lightBox();
    });

Is it possible to somehow trigger a Javascript function to rebind the handler after the M$AJAX request completes?

This is part of a series of projects I intend to undertake to teach myself how to do some cool things with AJAX in ASP.NET MVC. I intend to release the code on my website once complete so others can learn like I have. I tend to find there are so many example with JQuery -> PHP -> MySQL the open source stack. But very little with ASP.NET MVC.

Thanks,

Jon

  • 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-15T08:31:00+00:00Added an answer on May 15, 2026 at 8:31 am

    One of the AjaxOptions properties is an OnSuccess property that will call some JavaScript code after a successful AJAX request. Set its value to the name of a JavaScript function that then uses jQuery to activate the LightBox script.

    new AjaxOptions { UpdateTargetId = "gallery", OnSuccess="ActivateLightBox" })
    

    And some script:

    <script ...>
        function ActivateLightBox() {
            $(function () { 
                $('#gallery a').lightBox(); 
            }); 
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been playing around with subscribing elements to AJAX events in jQuery. I have
Playing around with customizing the appearance of the Wizard control in ASP.Net, and I've
I'm just playing around for the first time with jQuery's ajax functionality. I wanted
I was playing around with this code: http://jsfiddle.net/VmVAq/ As you can see, on page
I'm playing around with the new ASP.NET bundling feature and can't seem to get
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
I have been looking around the internet for examples of an AJAX function which
I just working with JSON data and am playing around with jQuery and Ajax
I am using HTML 5 for the first time, and playing around with this
Playing around with Google Maps these days, with some directions. I have a map

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.