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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:26:58+00:00 2026-05-26T13:26:58+00:00

I have a ul with 10 li’s which the user has populated through jquery

  • 0

I have a ul with 10 li’s which the user has populated through jquery sortable. Each li has a hidden span with the ID in it. How do I read the IDs and pass them into my C# code behind when the user clicks an ASP.NET button?

Here is my thought process:

  1. Build a jquery function that loops and retrieves all the IDs and passes them into an array.
  2. Pass only the array back to C#.
  3. In my code behind: read the array and do whatever I need from there.

My problem:

  1. I don’t know what jquery is involved to create the array
  2. I don’t know how to pass the array to the code behind
  3. I don’t know how to read the array in my code behind

Any help is appreciated.

Thanks!

    <li class="ui-state-default">
    <span id="competencyID">3</span>

    <h1><span id="competencyTitle">Comp Title</span></h1>   

</li>
<li class="ui-state-default">
    <span id="competencyID">18</span>

    <h1><span id="competencyTitle">Comp Title</span></h1>   

</li>
<li class="ui-state-default">
    <span id="competencyID">103</span>

    <h1><span id="competencyTitle">Comp Title</span></h1>   

</li>
<li class="ui-state-default">
    <span id="competencyID">6</span>

    <h1><span id="competencyTitle">Comp Title</span></h1>   

</li>
<li class="ui-state-default">
    <span id="competencyID">25</span>

    <h1><span id="competencyTitle">Comp Title</span></h1>   

</li>
  • 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-26T13:26:59+00:00Added an answer on May 26, 2026 at 1:26 pm

    First you need to make id’s unique, I would replace the id’s of the <span> tags with classes.

    Change:

    <li class="ui-state-default">
        <span id="competencyID">25</span>
    
        <h1><span id="competencyTitle">Comp Title</span></h1>   
    
    </li>
    

    To:

    <li class="ui-state-default">
        <span class="competencyID">25</span>
    
        <h1><span class="competencyTitle">Comp Title</span></h1>   
    
    </li>
    

    For your jQuery you can do something like this:

    $('#button_id').bind('click', function () {
        var arr = {};//create new object (empty)
        $('#ul_id').find('.competencyID').each(function (index, value) {
            arr[index] = $(value).text();
        });
        //send data to server-side script
        $.get('path/to_server.file', $.param(arr), function (response) {
            //this is the callback function, once your server-side script runs you can output data that you can retrieve here via the response variable
        });
    });
    

    Here is a jsfiddle of collecting the id’s and adding them to a JavaScript object: http://jsfiddle.net/rre47/1/

    –UPDATE–

    If you want to return an array of ids that can more easily be parsed by server-side scripts you can use the following code:

    Change:

    var arr = {}; to var arr = {'id' : []};

    And Change:

    $.param(arr) to decodeURIComponent($.param(arr))

    The output will look like this:

    id[]=3&id[]=18&id[]=103&id[]=6&id[]=25
    

    jsfiddle of the above code: http://jsfiddle.net/rre47/4/

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

Sidebar

Related Questions

Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
I have a text area in my form which accepts all possible characters from
Have an app that can use tts to read text messages. It can also
Have a bunch of classes which I need to do serialize and deserialize from/to
Have you ever tried working with a XAML file which contains thousand tons of

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.