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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:11:57+00:00 2026-05-26T06:11:57+00:00

In my application I have some table data that looks like this: <table> <tr>

  • 0

In my application I have some table data that looks like this:

<table>
    <tr>
        <th>Actions</th>
        <th>Text</th>
    </tr>
    @foreach( var item in Model.Items ) {
    <tr>
        <td>
            @Html.ActionLink("Edit", "Edit", "Items", new { @class = "edit-item-link", id = "edit-item-" + item.Id })
            @Html.ActionLink("Delete", "Delete", "Items", new { @class = "delete-item-link", id = "delete-item-" + item.Id })
        </td>
        <td>@item.Text</td>
    </tr>
    }
</table>

The view will create action links like the following:

<a href="/Items/Edit/1" class="edit-item-link" id="edit-item-1">Edit</a>

I am then using jquery to override the action:

$('.edit-item-link').live('click', function(e) {
    e.preventDefault();

    $.ajax({
        type: 'POST',
        url: ''
        dataType: 'json'
    });
});

When I pass the URL to the ajax call I want to use the following url: /Items/GetItemJson/1

How can I get the id value from the url without having to use a regex?

I don’t want to change the url in the action link because I will be using it in another way.

  • 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-26T06:11:58+00:00Added an answer on May 26, 2026 at 6:11 am

    The easiet approach would be to use data-* attributes

    @Html.ActionLink("Edit", "Edit", "Items", new { @class = "edit-item-link", data_id=item.Id,  id = "edit-item-" + item.Id })
    

    Which should render the following:

    <a href="/Items/Edit/1" class="edit-item-link" id="edit-item-1" data-id="1">Edit</a>
    

    And than in your jQuery you can use .data()

    $('.edit-item-link').live('click', function(e) {
        e.preventDefault();
        var theId = $(this).data("id");
        $.ajax({
            type: 'POST',
            url: ''
            dataType: 'json'
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have a sqlite database that looks like this: CREATE TABLE
In my Java application I have some copy-constructors like this public MyClass(MyClass src) {
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
In my WPF application I have some drawing functionality. I have solved this using
I am devloping smart device application in C#. In this application I have some
Most projects have some sort of data that are essentially static between releases and
I'm designing an application that will use Oracle , and we have this department
I have a working process, behind a web application, that is generating some records
I'm writing an application that indexes data for our stores, some of which are
I'm looking at building a Rails application which will have some pretty large tables

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.