locked
How can I simulate SelectedIndex="none" in accordion? RRS feed

  • Question

  • User-1698774246 posted

    Hi, I lost quite some time on this problem: I am trying to create a treeview-like menu using accordion. When the page initially loads I want all panes to be colapsed. I noticed that SelectedIndex must be assigned an integer value which determines the pane that is expanded. Is it possible to tell the accordion that I dont want to expand any of the panes?

    One thing I did is I created the first pane to be empty and set the SelectedIndex="0" to expand that pane, and it works, but it isn't very elegant solution because the whole accordion moves up a little when that empty pane is colapsed (when the user clicks on another pane). I even set height="0" on that pane. Anyone got a better solution?

    Thanks in advance

    Thursday, May 27, 2010 10:39 AM

Answers

All replies

  • User-364289655 posted

    I think the accordian is designed to always have one open, but you can try setting SelectedIndex="-1". If not, this is probably better suited for nested collaspible panels:

    http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/CollapsiblePanel/CollapsiblePanel.aspx 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 27, 2010 1:17 PM
  • User-1360095595 posted

    Try your luck with: SelectedIndex="-1" 

    Thursday, May 27, 2010 1:20 PM
  • User-1698774246 posted

    Thanks for the idea, and I tried it but it didn't work. When you specify SelectedIndex a value that doesn't have a coresponding pane, it automatically sets it to default value ("0")

    Update: tried and it works fine with adding an empty pane at the bottom of the accordion, so when it expands/colapses it doesn't mess up the other panes.

    @PNasser: Thanks for the sugestion, maybe I should have done it with the CollapsiblePanel control, but I think I can manage with accordion. I just don't have the time to rework the whole menu.

    Friday, May 28, 2010 3:14 AM
  • User-1360095595 posted

    I think the accordian is designed to always have one open, but you can try setting SelectedIndex="-1". If not, this is probably better suited for nested collaspible panels:

    http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/CollapsiblePanel/CollapsiblePanel.aspx 

     

    Nice recovery from your misstatement.

    Friday, May 28, 2010 6:15 AM
  • User-364289655 posted

    Which misstatement?

    Also, a side note- your signature is a C# <--> VB.net converter - do you know of any converter that can bulk translate an entire web site project (not web application unfortunately). Finally convinced people to make the move to C#, but it would be way to much work to manually translate it 

    Friday, May 28, 2010 12:02 PM
  • User-1360095595 posted

    No I'm not aware of any such tool.  You might create a new thread with your question.

    Friday, May 28, 2010 1:05 PM