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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:05:51+00:00 2026-05-21T20:05:51+00:00

I have an application under development using ASP.NET MVC 2 with jQuery. I have

  • 0

I have an application under development using ASP.NET MVC 2 with jQuery. I have a list of items displayed in my page and a set of actions that can be performed on each item. Rather than repeat the links or icons for each list item, we are displaying them in a pseudo-toolbar at the top of the list.

I am using the jQuery UI Selectable plug-in to manage selecting the list items. Now I need to accomplish two things:

  1. When I click one of the buttons, I need to submit the id of the selected list item as an argument to the request. For example, if I click the “Edit” button, it should correspond to the action method Edit(int id) with ‘id’ being pulled from the selected item in the list. (Btw, ‘id’ is not the element id but the identifier from the server that I need to embed in the response so I can use it to identify the item back on the server.)

  2. I want to be able to enable/disable buttons based on other factors. For example, perhaps one list item can’t be edited because it is ‘closed.’ Once I am able to determine which item is selected (using $(“.ui-selected”) I presume), what is the best way for me to communicate the other attributes I need to determine which buttons are enabled or disabled? Are hidden fields my only (best) option to pass such info to the client-side script?

UPDATE

After reading more I feel I should clarify that I do NOT want to perform the action asynchronously – so no AJAX. I am looking at using the normal action-link type behavior for the buttons.

  • 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-21T20:05:52+00:00Added an answer on May 21, 2026 at 8:05 pm

    For the sake of closure, here’s what I ended up with (please comment if you have a better solution!):

    In my View, I have implemented a “stub” form like this:

    <% using (Html.BeginForm("Command", "MyController"))
       { %>
       <%= Html.Hidden("CommandName") %>
       <%= Html.Hidden("CommandArgument") %>
    <% } %>
    

    As mentioned above, I am using the jQuery Selectable plug-in to manage the list of items and their selection. Each item contains hidden fields for any data-points I need to use to determine which of the buttons are enabled or disabled. Here is how I have implemented the Selectable plug-in:

    var selectedValue = null;
    var selectedItemHasChildren = false;
    
    $(function () {
        $(".my_list").selectable({
            filter: "tr",
            selected: function (e, ui) {
                var item = $(ui.selected).children("td");
    
                selectedValue = item.children("input[name=ItemID]").first().val();
                selectedItemHasChildren = (item.children("input[name=HasChildren]")
                                          .first()
                                          .val() == 1);
    
                UpdateButtonStates();
            }
        });
    });
    

    The UpdateButtonStates method uses the two variables to determine which buttons should be visible and/or enabled.

    Each button, in my case, is actually implemented as an image button – so a span with an <a> wrapper. The href property is directed towards the following method:

    function Button_Click(action) {
        $("#CommandName").val(action);
        $("#CommandArgument").val(selectedValue);
        $("form").submit();
    }
    

    As you can see, I’m using the form defined above to pass the desired action and the supporting argument back to my controller. I could have, of course, eliminated the CommandName form field and redirected the form itself to the desired action using something like $(“form”).attr(“action”, action). I chose to go this route because I didn’t want the individual actions exposed by my API. Plus I thought this was convenitently similar to the Command event exposed by traditional ASP.NET Button server controls so the learning curve for other developers would be minimized.

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

Sidebar

Related Questions

I have an ASP.NET 2.0 application under IIS that has the functionnality of exporting
I have a WPF application using Aero Glass. When using the application under a
I have a Swing Application running under Linux, that has problems to display accented
We have an issue related to a Java application running under a (rather old)
I have a WPF application that runs fine under XP as an administrator. When
I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons,
I have installed pylons based application from egg, so it sits somewhere under /usr/lib/python2.5/site-packages.
In Netbeans (I have the 6.5 version), in the project properties under Application> Webstart
I have an MVC 3 application and am trying to display a custom validation
I have two applications under tomcat/webapps folder. tomcat/webapps/App1 tomcat/webapps/App2 Both applications share the same

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.