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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:36:31+00:00 2026-06-06T17:36:31+00:00

How can I reference the clicked Ajax.ActionLink from within it’s OnBegin function? cshtml @Ajax.ActionLink(

  • 0

How can I reference the clicked Ajax.ActionLink from within it’s OnBegin function?

cshtml

@Ajax.ActionLink(
    typeName,
    "OrderQueueRows",
    new 
    {
        typeNames = Model.Name,
        includeDerivedTypes = ViewBag.IncludeDerivedTypes,
        excludeCompletedOrders = ViewBag.ExcludeCompletedOrders
    },
    new AjaxOptions {
        LoadingElementId="ajax-loading",
        OnBegin = "highlightFilter",
        UpdateTargetId = "order-queue-body"
    },
    new { @class = "show-exclusively" })

javascript

function highlightFilter() {
    $link = $(this);
    $link.css('color', 'red');
    $link.siblings().not($link).css('color', '');
}
  • 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-06T17:36:33+00:00Added an answer on June 6, 2026 at 5:36 pm

    You cannot achieve this with the out-of-the-box Ajax.* helpers because they do not pass the element to the onBeforeSend callback. The way Microsoft implemented it, they pass the xhr object and not the element that was clicked. So one possibility is to modify the jquery.unobtrusive-ajax.js script in order to pass this information to the callback. On line 85 you will see the following inside the beforeSend callback:

    result = getFunction(element.getAttribute("data-ajax-begin"), ["xhr"]).apply(this, arguments);
    

    All you have to do is to modify it like this:

    result = getFunction(element.getAttribute("data-ajax-begin"), ["xhr"]).apply(element, arguments);
    

    and if you needed to have both the element and the xhr object inside your OnBegin callback:

    result = getFunction(element.getAttribute("data-ajax-begin"), ["xhr"]).apply({ xhr: this, element: element }, arguments);
    

    Now, your code is going to work and this will represent the element:

    function highlightFilter() {
        $link = $(this);
        $link.css('color', 'red');
        $link.siblings().not($link).css('color', '');
    }
    

    Another possibility is to simply replace the Ajax.ActionLink with a standard Html.ActionLink and then write the corresponding jQuery code to subscribe to the .click event and trigger the AJAX request. Personally it’s probably what I would do.

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

Sidebar

Related Questions

i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
Given systems A and B, how can i reference domain entities from system A
How can I reference the cell object that was clicked inside the didSelectRowAtIndexPath:(NSIndexPath *)indexPath
can some on help me on how i can reference images i have all
is there a method to link specific files so that I can reference them
Using import aliasing in one file/class, we can reference class library namespaces by assigning
GWT in Action, 2ed (MEAP), p.218 says that we can reference server-side classes in
how can i reference a display object's coordinates according to it's parent object or
It seems that Visual Basic can not reference sheets according to user-modified sheet names.
I made a Dictionary <string, string> collection so that I can quickly reference the

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.