I've been Googling for so long now and I cannot find a straight answer or correct solution to my problem (especially when I'm a novice at JavaScript/C#!).
I have got an Accordion Control on my MasterPage which acts as a menu. My problem is that when I click on a button within the content pane it displays a new page within the ContentPlaceHolder, but the Accordion resets itself back to SelectedIndex = 0. How
can I keep the SelectedIndex = 1 open when I'm response.redirected to another page?
I have heard about sessions but I can't make any sense of them. Any suggestions or solutions would be great!
Many thanks.
accordion control c# javascript master page selectedindex menu
If you do a Response.Redirect the asp request page as a new request to the server. The drop down list selected index as stored in viewstate.Since the request is new request to the server there will not be any viewstate information for the new page.
Please first add the namspace of Ajax Control Toolkit in ur code behind file so that u can create an accordion objec in the codet . In page load event find the accordion control on the master page by using this method : Master.FindControl("Id of ur accordioncontrol") . Don't forget to type cast it. Then set the index. Thus while loading this page menu will show the appropriate accordion pane open.
But now I have a different problem, still relating to the Accordion control. Now that I have the SelectedIndex working, I'm stuck on how to change the button to a different colour...
Here's the background: Myself and my fiancee have started up an online pet store and when a user clicks on 'For Kittens & Cats' the content pane appears with sub-category buttons. Now when a user then clicks on a sub-category I want this image to change
to a selected image on the relevant page. At the moment I am using a and a:active in the CSS to change this but am stuck because when it does change page this button is no longer selected.
If you have no idea what I've just said, please visit my very unfinished website at
www.touchofglitz.co.uk and click on 'For Kittens & Cats' and then 'ID Tags'.
Please help me! Many thanks once again.
accordion control c# javascript master page selectedindex menu
The ones I am talking about are in the Accordion control on the left hand side. When the user clicks 'For Kittens & Cats', the content pane appears with the unselected light purple button 'ID Tags'. Now when the user clicks on 'ID Tags' and is redirected
to the ID Tags page, I want to be able to change the 'ID Tags' button image so that it changes colour to dark purple (the same way as the 'For Kittens & Cats' button is unselected and then selected).
For the 'ID Tags' button I am using CSS 'a' hyperlink tag and a:active as well to change from one image to another. This works fine BUT it needs to keep to the a:active image on the selected page to basically let the user know what they selected and where
they are.
In the same way, in the page load event of the Id tags page , find the "ID tags" button control. and set its background image there. Thus when the ID tags page will be displayed ur button will look as selected.
russellevans...
0 Points
8 Posts
Accordion Control in MasterPage does not remember its SelectedIndex
Feb 21, 2009 12:37 PM|LINK
Hey guys, I hope anybody out there could help me!
I've been Googling for so long now and I cannot find a straight answer or correct solution to my problem (especially when I'm a novice at JavaScript/C#!).
I have got an Accordion Control on my MasterPage which acts as a menu. My problem is that when I click on a button within the content pane it displays a new page within the ContentPlaceHolder, but the Accordion resets itself back to SelectedIndex = 0. How can I keep the SelectedIndex = 1 open when I'm response.redirected to another page?
I have heard about sessions but I can't make any sense of them. Any suggestions or solutions would be great!
Many thanks.
accordion control c# javascript master page selectedindex menu
Prabhubeec
Member
162 Points
50 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 22, 2009 08:07 AM|LINK
If you do a Response.Redirect the asp request page as a new request to the server. The drop down list selected index as stored in viewstate.Since the request is new request to the server there will not be any viewstate information for the new page.
Bober Song -...
All-Star
34686 Points
2167 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 23, 2009 04:53 AM|LINK
Hi,
When you response.redirect to another page, you can pass parameter via Session.
page1.aspx:
protected void Button1_Click(object sender, EventArgs e) { Session["selectedIndex"] = "1"; }Page2.aspx:More information, please check following link:
ASP.NET Session State
http://msdn.microsoft.com/en-us/library/ms972429.aspx
Session FAQ
http://www.syncfusion.com/faq/aspnet/web_c9c.aspx
Underpinnings of the Session State Implementation in ASP.NET
http://msdn.microsoft.com/en-us/library/aa479041.aspx
Let me know whether that answers your question, or if I've missed something.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
shweta_bhand...
Member
25 Points
56 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 23, 2009 08:06 AM|LINK
Hi,
I also used the Accordion control as a menu on the master page and faced the same problem.
Here is the solution.
On the Page_Load event of ur aspx page containing the content pane, write down the following code
using System;
using AjaxControlToolkit;
protected void Page_Load(object sender, EventArgs e)
{
Accordion accordioMenu = (Accordion) Master.FindControl("AccordionMenu");
accordioMenu.SelectedIndex = 2;
}
Please first add the namspace of Ajax Control Toolkit in ur code behind file so that u can create an accordion objec in the codet . In page load event find the accordion control on the master page by using this method : Master.FindControl("Id of ur accordion control") . Don't forget to type cast it. Then set the index. Thus while loading this page menu will show the appropriate accordion pane open.
Please feel free to ask any doubt.
Please mark it as answer if found useful
russellevans...
0 Points
8 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 23, 2009 11:36 AM|LINK
Hi shweta_bhandari
Many thanks for that piece of code - it works! Finally, I can carry on with my website!
Once again, many many thanks.
Russell
shweta_bhand...
Member
25 Points
56 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 23, 2009 11:43 AM|LINK
wow! that's great! [:)]
please mark it as answer [Yes]
russellevans...
0 Points
8 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 24, 2009 11:08 AM|LINK
Yep already have!
But now I have a different problem, still relating to the Accordion control. Now that I have the SelectedIndex working, I'm stuck on how to change the button to a different colour...
Here's the background: Myself and my fiancee have started up an online pet store and when a user clicks on 'For Kittens & Cats' the content pane appears with sub-category buttons. Now when a user then clicks on a sub-category I want this image to change to a selected image on the relevant page. At the moment I am using a and a:active in the CSS to change this but am stuck because when it does change page this button is no longer selected.
If you have no idea what I've just said, please visit my very unfinished website at www.touchofglitz.co.uk and click on 'For Kittens & Cats' and then 'ID Tags'.
Please help me! Many thanks once again.
accordion control c# javascript master page selectedindex menu
shweta_bhand...
Member
25 Points
56 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 24, 2009 11:31 AM|LINK
Hi,
r u talking about these buttons :- Star ID Tags, Round ID tags, Heart ID tags.... ?
Which image u want to change, the one which is above these buttons?
Which control u r using to display this image?
russellevans...
0 Points
8 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Feb 24, 2009 12:01 PM|LINK
Hey
The ones I am talking about are in the Accordion control on the left hand side. When the user clicks 'For Kittens & Cats', the content pane appears with the unselected light purple button 'ID Tags'. Now when the user clicks on 'ID Tags' and is redirected to the ID Tags page, I want to be able to change the 'ID Tags' button image so that it changes colour to dark purple (the same way as the 'For Kittens & Cats' button is unselected and then selected).
For the 'ID Tags' button I am using CSS 'a' hyperlink tag and a:active as well to change from one image to another. This works fine BUT it needs to keep to the a:active image on the selected page to basically let the user know what they selected and where they are.
Hope this helps!
shweta_bhand...
Member
25 Points
56 Posts
Re: Accordion Control in MasterPage does not remember its SelectedIndex
Mar 04, 2009 12:27 PM|LINK
Hi friend!
Replying u so late [:$] was busy with my work!
In the same way, in the page load event of the Id tags page , find the "ID tags" button control. and set its background image there. Thus when the ID tags page will be displayed ur button will look as selected.
Hope this will help u.
Please feel free to ask any doubt