I have four accordion panes and every pane have almost 3 to 4 link button. All is working fine except after every postback 1st accordion is appear. Whereas I want to remain in the working accordion. I have used master page to the Accordion Controle.
I am using visual studio 2008 and download atlas ajax toolkit. My question is that on every postback 1st accordion pane open. Whereas I want to get the Accordion pane where I am working.
For example when I was in accordion pane # 1 I should be in the 1st accordion pan # 1 That is ok
But when I am working in accordion pane # 2 I should be in the 2nd accordion pane #2, but here I comes on the 1st Accordion pane.
I think, you are right that this is bug because I use the Accordion control in vs 2005 there it is working fine. But when I used it in the Vs 2008 (Atlas Ajax toolkit 3.5) here I found this error. That is on every click postback it runs to 1st AccordionPane.
Now I download the latest Dll of Atlas Ajax Toolkit but found again this error.
Based on my understanding, your situation is in each Content areas of Accordion Control there are many LinkButtons used to link to each Page, and the issue is the SelectedIndex of the Accordion has not been saved. If I have misunderstood you, please feel
free to tell me.
Actually, if you postBack to this page itself, for example, add a ASP:Button and click it, the selected state of the Accordion could be saved.
But in your application, the page which contains Accordion would be opened from another one, then the Accordion would be initialized with its first panel opend.
To achieve your goal, we recommend saving the SelectedIndex in the Cookie of the page and change it in the selectedIndexChanged event, then get it when the page is on load.
Please refer to this code:
var ad;
function pageLoad(){
ad = $find("Accordion1_AccordionExtender");
//Get the value from Cookie
getIndexFromCookie();
ad.add_selectedIndexChanged(function(){
//Save the SelectedIndex in the Cookie
saveIndexInCookie();
} );
}
//Please write the two functions in your favorite way
function getIndexFromCookie(){
//ad.set_SelectedIndex(parseFloat(GetCookie("selectIndex")));
}
function saveIndexInCookie(){
//DeleteCookie("selectIndex");
//SetCookie("selectIndex",ad.get_SelectedIndex());
}
I hope all above can help you, any other questions, please let me know, thanks.
Best regards,
Zhi-Qiang Ni
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
Now I have get the cause, That is when I used the java script function so Accoridion's behave not good. But when I remove the Javascript function it is working fine.
Can any body tell me why Accoridion is not working with Java Script.
I tried two type of java script but both get the problem,
1stly I create the java script function in the Head and used this function to Onclientclick.
<asp:LinkButton
ID="LB10"
runat="server"
OnClientClick="return redirect('Default.aspx')"
>Home</asp:LinkButton>
2ndly I used the function direct in the OnClientClick.
Both java script function working perfectly, because I have used the expression validator therefore I need to use "OnClientClick".
Problem is that due to these function Accoridion is not working perfectly. I mean on every click 1st pane is open, whereas I have four Panes and want to get the pane on which I am working.
naveedbaig
Member
28 Points
158 Posts
How to get Accordion selected index at runtime
May 02, 2008 10:27 AM|LINK
Hi,
I have created a simple ajax web site using Accordion Controle. And use the link button in the content tags like
<asp:LinkButton ID="LB22" runat="server" Font-Underline="false" PostBackUrl="Settings.aspx" >General Settings</asp:LinkButton>I have four accordion panes and every pane have almost 3 to 4 link button. All is working fine except after every postback 1st accordion is appear. Whereas I want to remain in the working accordion. I have used master page to the Accordion Controle.
Thanks,
naveedbaig
vik20000in
All-Star
25882 Points
3993 Posts
MVP
Re: How to get Accordion selected index at runtime
May 02, 2008 11:07 AM|LINK
This link might help
http://blog.benhall.me.uk/2007/01/aspnet-ajax-accordion-control-change.html
www.vikramlakhotia.com
Please mark the answer if it helped you
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: Maintain Accordion selected index between postbacks
May 02, 2008 11:21 AM|LINK
Hi,
What i understand is that you can't maintain the selected pane of the accordion between postbacks,
I read it was a bug an its recently fixed ! please make sure you have the latest ajax toolkit dll ,
I suggest to try to set the Accordion AutoSize proeprty to any value ,
<cc1:Accordion ID="Accordion1" AutoSize="Fill" ....accordian maintain selectedindex
naveedbaig
Member
28 Points
158 Posts
Re: Maintain Accordion selected index between postbacks
May 02, 2008 03:09 PM|LINK
thanks for reply,
I am using visual studio 2008 and download atlas ajax toolkit. My question is that on every postback 1st accordion pane open. Whereas I want to get the Accordion pane where I am working.
For example when I was in accordion pane # 1 I should be in the 1st accordion pan # 1 That is ok
But when I am working in accordion pane # 2 I should be in the 2nd accordion pane #2, but here I comes on the 1st Accordion pane.
naveedbaig
naveedbaig
Member
28 Points
158 Posts
Re: How to get Accordion selected index at runtime
May 02, 2008 03:15 PM|LINK
Thanks vik20000in,
As my understanding this example is works for Index changed manually. But I want to get the accordion index on the run time .
naveedbaig
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: How to get Accordion selected index at runtime
May 02, 2008 03:27 PM|LINK
Did you tried to set the accordion AutoSize property , try to set it to any value ,
e.g
<cc1:Accordion ID="Accordion1" AutoSize="Fill" ....naveedbaig
Member
28 Points
158 Posts
Re: How to get Accordion selected index at runtime
May 03, 2008 02:49 AM|LINK
Thanks Anas
I have checked it with the Accordion property using AutoSize= "Fill", But there is nothing change. I still get the 1st accordion on postback.
Naveedbaig.
naveedbaig
Member
28 Points
158 Posts
Re: Maintain Accordion selected index between postbacks
May 06, 2008 08:01 AM|LINK
Hi Anas,
I think, you are right that this is bug because I use the Accordion control in vs 2005 there it is working fine. But when I used it in the Vs 2008 (Atlas Ajax toolkit 3.5) here I found this error. That is on every click postback it runs to 1st AccordionPane.
Now I download the latest Dll of Atlas Ajax Toolkit but found again this error.
naveedbaig
Zhi-Qiang Ni...
All-Star
33491 Points
2952 Posts
Microsoft
Re: How to get Accordion selected index at runtime
May 09, 2008 07:00 AM|LINK
Hi naveedbaig,
Based on my understanding, your situation is in each Content areas of Accordion Control there are many LinkButtons used to link to each Page, and the issue is the SelectedIndex of the Accordion has not been saved. If I have misunderstood you, please feel free to tell me.
Actually, if you postBack to this page itself, for example, add a ASP:Button and click it, the selected state of the Accordion could be saved.
But in your application, the page which contains Accordion would be opened from another one, then the Accordion would be initialized with its first panel opend.
To achieve your goal, we recommend saving the SelectedIndex in the Cookie of the page and change it in the selectedIndexChanged event, then get it when the page is on load.
Please refer to this code:
I hope all above can help you, any other questions, please let me know, thanks.
Best regards,
Zhi-Qiang Ni
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
naveedbaig
Member
28 Points
158 Posts
Re: How to get Accordion selected index at runtime
May 09, 2008 07:49 AM|LINK
Hi Zhi-Qiang Ni,
Now I have get the cause, That is when I used the java script function so Accoridion's behave not good. But when I remove the Javascript function it is working fine.
Can any body tell me why Accoridion is not working with Java Script.
I tried two type of java script but both get the problem,
1stly I create the java script function in the Head and used this function to Onclientclick.
<script type="text/javascript" language="javascript">function
redirect(thisform){ window.location.href =thisform; return false; }
</script>
<asp:LinkButton ID="LB10" runat="server" OnClientClick="return redirect('Default.aspx')" >Home</asp:LinkButton> 2ndly I used the function direct in the OnClientClick.<
asp:LinkButton ID="LB10" runat="server" Font-Underline="false" OnClientClick="location.href="Default.aspx';return false;">Home</asp:LinkButton>Both java script function working perfectly, because I have used the expression validator therefore I need to use "OnClientClick".
Problem is that due to these function Accoridion is not working perfectly. I mean on every click 1st pane is open, whereas I have four Panes and want to get the pane on which I am working.
naveedbaig