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

The Archive Base Latest Questions

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

I have a jQuery accordion in a page in ASP:Net MVC application in which

  • 0

I have a jQuery accordion in a page in ASP:Net MVC application in which I want to set the active accordion at runtime.

My code is as follows:

<script type="text/javascript">
    $(document).ready(function() {
        var accordionindex = $("#UIPViewModel_ActiveAccordion").val();
        alert("Setting active index to " + accordionindex);
        $("#accordion").accordion('activate', accordionindex );
    });
</script>

You will see the last line sets the active accordion. When I use this code it always acts like I have used active : false and ALL of the accordions are closed even though the alert displays the correct runtime value.

I have also tried simply using the following which is the same:

$(“#accordion”).accordion(‘activate’, $(“#UIPViewModel_ActiveAccordion”).val());

When I change the last line to :

$(“#accordion”).accordion(‘activate’, 2 ); (i.e. hard-coded). It always works correctly!

Can anyone see what´s wrong?
Where i am making my mistake??

  • 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-12T13:58:29+00:00Added an answer on May 12, 2026 at 1:58 pm

    The variable being returned by val() is a string and accordion is expecting a number. Try:

        var accordionindex = $("#UIPViewModel_ActiveAccordion").val();
        accordionindex = parseInt(accordionindex, 10);  // convert a string to a number
        alert("Setting active index to " + accordionindex);
        $("#accordion").accordion('activate', accordionindex );
    
    • 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 MVC 3 (Razor) Web Application, with a particular page which
I have a simple JQuery enabled ASP.NET page: <script> $(document).ready(function() { $(#accordion).accordion(); }); </script>
I have a Jquery Accordion and I have a asp.net GridView below that. When
I have a jquery accordion on an asp.net aspx weppage. Inside the panes, I
I want to have two different jQuery UI accordion menus on the same page,
I have the jQuery Accordion set up on a page of mine, and the
I have set up jQuery accordion in my page as $(document).ready(function() { $(#MGH).accordion('activate', 1);
I am using JQuery Accordion. I have this page here: http://www.hauppauge.com/site/support/support_colossus.html#tabs-6 What happens is
I have a jquery accordion that I want to use nth-child to assign odd
I have a html-page where used jquery-ui accordion. Now I have to add in

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.