Visual Studio .NET - ajaxToolkit ,AccordionPane

Asked By Saurabh ......
20-Oct-08 04:04 AM

i m using ajaxToolkit:AccordionPane with 5 pane.

i want to preserve selected pane index on each post back .

is it posible ??

i want this because i m using AccordionPane on master page and there are link buttons in each pane to navigate diff. contant page . now when i expand 3rd pane and click on any link than masterpage reloaded and selected index property of AccordionPane  change to 0;

 

 

 

re  re

20-Oct-08 04:26 AM

var lastIndex = this._selectedIndex;
        var currentPane=this.get_Pane(index);
        var lastPane=this.get_Pane(lastIndex);

if (!force && (currentPane == lastPane)) {
            return;
        }
// Raise the selectedIndexChanging event but don't change the selected index
        // if the handler set the cancel property to true

        var eventArgs = new AjaxControlToolkit.AccordionSelectedIndexChangeEventArgs(lastIndex, index);
        this.raiseSelectedIndexChanging(eventArgs);
        if (eventArgs.get_cancel()) {
            return;
        }
      
        //This sets the header CSS class to the non-selected case.
        if(lastPane)
        {
            lastPane.header.className = this._headerCssClass;
        }
       
        //This sets the selected header CSS class if available.
        if(currentPane)
        {
            currentPane.header.className = (this._headerSelectedCssClass == '') ?
                this._headerCssClass : this._headerSelectedCssClass;
        }
      
        this._selectedIndex = index;
       
        // Save the selected pane to preserve on postbacks
        this.set_ClientState(this._selectedIndex);
       
        // Animate the pane changes if required
        if (animate) {
            this._changePanes(lastIndex);
        }
       
        // Raise the selectedIndexChanged event and the propertyChanged event.  We include
        // both events because many users have expressed that the propertyChanged event is
        // not discoverable.

        this.raiseSelectedIndexChanged(new AjaxControlToolkit.AccordionSelectedIndexChangeEventArgs(lastIndex, index));
        this.raisePropertyChanged('SelectedIndex');
    },
http://forums.asp.net/t/1262353.aspx

yes ofcourse  yes ofcourse

20-Oct-08 08:16 AM

look below and ask your questions

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

using System.Globalization;

using System.Threading;

using System.Resources;

using System.Reflection;

 

namespace Dewelloper.UserControl

{

public partial class UserControls_AccordionMenu : System.Web.UI.UserControl

{

private static Int32 _index = 0;

private ResourceManager _rm;

private static string _language = string.Empty;

private static string _one = "";

private static string _two = "";

private static string _tree = "";

private static string _foor = "";

private static string _five = "";

private static string _six = "";

private static string _seven = "";

private static string _eight = "";

public string Language

{

get {

return _language;

}

set {

_language = value;

}

}

protected void Page_Load(object sender, EventArgs e)

{

if (Request.QueryString["Type"] != null)

_index = Convert.ToInt32(Request.QueryString["Type"]) - 1;

Firer();

MyAccordion.SelectedIndex = _index;

SetLanguage();

}

private void SetLanguage()

{

if (_one == "")

{

if (_language == string.Empty)

_language = Localization.GetCulturelName("Accordion");

else _language += "Accordion";

 

bool available = true;

string text1 = string.Empty;

_rm = new ResourceManager("Resources." + _language, System.Reflection.Assembly.Load("App_GlobalResources"));

CultureInfo ci = Thread.CurrentThread.CurrentCulture;

try

{

text1 = _rm.GetString("Articales", ci);

}

catch (Exception ex)

{

available = false;

}

if (available)

{

one.Text = _rm.GetString("DesktopDevelopment", ci);

two.Text = _rm.GetString("WebDevelopment", ci);

tree.Text = _rm.GetString("EnterpriseSysems", ci);

foor.Text = _rm.GetString("MultiMedia", ci);

five.Text = _rm.GetString("Database", ci);

six.Text = _rm.GetString("Platforms Framework Libraries", ci);

seven.Text = _rm.GetString("Languages", ci);

eight.Text = _rm.GetString("GeneralPrograming", ci);

_one = one.Text;

_two = two.Text;

_tree = tree.Text;

_foor = foor.Text;

_five = five.Text;

_six = six.Text;

_seven = seven.Text;

_eight = eight.Text;

}

else

{

_rm = new ResourceManager("Resources.en_Accordion", System.Reflection.Assembly.Load("App_GlobalResources"));

one.Text = _rm.GetString("Articales", ci);

two.Text = _rm.GetString("Forums", ci);

tree.Text = _rm.GetString("Controls", ci);

foor.Text = _rm.GetString("Culturels", ci);

five.Text = _rm.GetString("Database", ci);

six.Text = _rm.GetString("Platforms Framewoek Libraries", ci);

seven.Text = _rm.GetString("Languages", ci);

eight.Text = _rm.GetString("GeneralPrograming", ci);

}

}

else

{

one.Text = _one;

two.Text = _two;

tree.Text = _tree;

foor.Text = _foor;

five.Text = _five;

six.Text = _six;

seven.Text = _seven;

eight.Text = _eight;

}

}

public void Firer()

{

LoadAcordionMenu();

}

private void LoadAcordionMenu()

{

SqlConnection con = DbBuilder.GetConnection();

SqlCommand cmd = new SqlCommand("Select * from Subjects where IsActive=1", con);

try

{

if (con.State != ConnectionState.Open)

con.Open();

SqlDataReader dr = cmd.ExecuteReader();

while(dr.Read())

{

if (Convert.ToInt32(dr["Type"]) == 1)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString()

+ "&Type=1\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">"

+ dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneOne").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 2)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=2\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneTwo").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 3)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=3\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneTree").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 4)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=4\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneFour").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 5)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=5\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneFive").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 6)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=6\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneSix").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 7)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=7\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneSeven").Controls[1].Controls.Add(lt);

}

else if (Convert.ToInt32(dr["Type"]) == 8)

{

Literal lt = new Literal();

lt.Text = "<a href=\"Search.aspx?CatId=" + dr["Category"].ToString() + "&Type=8\" class=\"accordionItems\"><div onmouseover=\" this.style.border='1px solid Lime'; this.style.color = 'Black'; this.style.cursor='hand';\" onmouseout=\"this.style.color = 'Gray'; this.style.border='0px'; \">" + dr["Title"].ToString() + "</div></a>";

MyAccordion.FindControl("AccordionPaneEight").Controls[1].Controls.Add(lt);

}

}

}

catch (Exception ex)

{

string err = ex.Message;

}

finally

{

con.Close();

}

}

}

}

 

this is a nice menu, like one comes your gate so that ? ask any question

<ajaxToolkit:Accordion ID="MyAccordion" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"

HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"

FadeTransitions="false" FramesPerSecond="40" TransitionDuration="250" AutoSize="None"

RequireOpenedPane="false" SuppressHeaderPostbacks="true">

<Panes>

<ajaxToolkit:AccordionPane ID="AccordionPaneOne" runat="server">

<Header>

<asp:LinkButton runat="server" ID="one" style="background-color: Silver; color:Black;" Width="150" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneTwo" runat="server">

<Header>

<asp:LinkButton runat="server" ID="two" style="background-color: Silver; color:Black;" Width="150" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneTree" runat="server">

<Header>

<asp:LinkButton runat="server" ID="tree" Width="150" style="background-color: Silver; color:Black;" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneFour" runat="server">

<Header>

<asp:LinkButton runat="server" ID="foor" Width="150" style="background-color: Silver; color:Black;" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneFive" runat="server">

<Header>

<asp:LinkButton runat="server" ID="five" Width="150" style="background-color: Silver; color:Black;" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneSix" runat="server">

<Header>

<asp:LinkButton runat="server" ID="six" Width="150" style="background-color: Silver; color:Black;" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneSeven" runat="server">

<Header>

<asp:LinkButton runat="server" ID="seven" Width="150" style="background-color: Silver; color:Black;" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPaneEight" runat="server">

<Header>

<asp:LinkButton runat="server" ID="eight" Width="150" style="background-color: Silver; color:Black;" onmouseover="this.style.border='1px solid Navy'; this.style.color = 'White'; this.style.cursor='hand';" onmouseout="this.style.color = 'Black'; this.style.border='0px';" ></asp:LinkButton>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

</Panes>

</ajaxToolkit:Accordion>

try this for reference  try this for reference

20-Oct-08 09:19 AM
Creating Your Accordion Solution

Follow the easy steps below to create your solution.

1.    Start your Visual Studio 2005 IDE

2.    Choose Create Web Site from the menu

3.    In this sample application we will use the Visual Basic language for the sample application

4.    Name the solution AccordionSample

5.    Choose ASP.NET AJAX Control Toolkit Web Site

6.    Choose File System in the location box

7.    Click OK to create the project

8.    Visual Studio 2005 will create your project with a Default.aspx page and most probably a readme.txt. Go ahead, get rid of the latter file.

9.    Open Default.aspx page in design view.

10. You noticed that there is a control on the page already called Script Manager. (Well, AJAX is really a script based implementation of the language JavaScript). In Short, Script Manager control manages client script for Microsoft ASP.NET AJAX pages. By default, the Script Manager control registers the script for the Microsoft AJAX Library with the page. This enables client script to use the type system extensions and to support features such as partial-page rendering and Web-service calls.

11. Now drag a Accordion Control from the Toolkit and drop it on the form in design mode.

12. It is preferable if you create a style sheet as included in Listing 1. (If you do not create this style sheet, you will end up with an accordion with no color unless you go and specify every style item by yourself).

Listing 1 - StyleSheet.css content

/* Accordion */
.accordionHeader
{
    border: 1px solid #2F4F4F;
    color: white;
    background-color: #2E4d7B;
      font-family: Arial, Sans-Serif;
      font-size: 12px;
      font-weight: bold;
    padding: 5px;
    margin-top: 5px;
    cursor: pointer;
}
 
#master_content .accordionHeader a
{
      color: #FFFFFF;
      background: none;
      text-decoration: none;
}
 
#master_content .accordionHeader a:hover
{
      background: none;
      text-decoration: underline;
}
 
.accordionHeaderSelected
{
    border: 1px solid #2F4F4F;
    color: white;
    background-color: #5078B3;
      font-family: Arial, Sans-Serif;
      font-size: 12px;
      font-weight: bold;
    padding: 5px;
    margin-top: 5px;
    cursor: pointer;
}
 
#master_content .accordionHeaderSelected a
{
      color: #FFFFFF;
      background: none;
      text-decoration: none;
}
 
#master_content .accordionHeaderSelected a:hover
{
      background: none;
      text-decoration: underline;
}
 
.accordionContent
{
    background-color: #D3DEEF;
    border: 1px dashed #2F4F4F;
    border-top: none;
    padding: 5px;
    padding-top: 10px;
}

13. Now go back to default.aspx and open it in source view (nice HTML Tags)…

14. If you have added the style sheet…Go to the head section and after the title section, add the listing 2 in order to include the style sheet to the page.

Listing 2 - Style Sheet Link Reference

<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

15. In the Accordion Tag line make them as in listing 3. Notice the use of some additional tags for the accordion. The FadeTransitions is used to create the effect of smooth sliding. Selected Indexed is used to open a pane by default in our case it is the first pane. Transition duration is giving in milliseconds to specify how much to take to perform the total opening. And last, the two style association from the style sheet to give the accordion some color as specified in the style sheet.

Listing 3 - Accordion Specs in Source Mode

<ajaxToolkit:Accordion ID="Accordion1" runat="server" FadeTransitions="True" 
SelectedIndex="0" TransitionDuration="300"  HeaderCssClass="accordionHeader" 
ContentCssClass="accordionContent">

16. Now we have our accordion, we have to add panes to it. However, before adding panes we have to add the panes section inside the accordion.

17. After adding the pane section, you can create as many panes as you like. But please note that every pane should have a header and a content tags.

18. In order how I did construct my panes, take a look at listing 4.

Listing 4 - The complete pane section in HTML

<Panes>
<ajaxToolkit:AccordionPane id="AccordionPane1" runat="server">
<Header> AJAX PANE</Header>
<Content>
AJAX HAS BEEN KNOW TO ENHANCE USER INTERFACE<br />
AJAX HAS BEEN KNOW TO ENHANCE USER INTERFACE<br />
AJAX HAS BEEN KNOW TO ENHANCE USER INTERFACE<br />
AJAX HAS BEEN KNOW TO ENHANCE USER INTERFACE<br />
</Content>
</ajaxToolkit:AccordionPane>
<ajaxToolkit:AccordionPane id="AccordionPane2" runat="server">
<Header>MY TEST PANE
</Header>
<Content>
THIS IS JUST A TEST OF PANE CONTENT<br />
THIS IS JUST A TEST OF PANE CONTENT<br />
THIS IS JUST A TEST OF PANE CONTENT<br />
</Content>
</ajaxToolkit:AccordionPane>
<ajaxToolkit:AccordionPane id="AccordionPane3" runat="server">
<Header>THIS IS LAST PANE
</Header>
<Content>
HOPE YOU LIKE WHAT YOU SEE<br />
THIS IS JUST A TEST OF PANE CONTENT<br />
HOPE YOU LIKE WHAT YOU SEE<br />
</Content>
</ajaxToolkit:AccordionPane>
</Panes>

19. Please note that coding was necessary here. Also note that the panes can contain any HTML tags you like.

The final output will look like the figures shown below

Figure 1 - The Default Output

Figure 2 - Output when the second pane is clicked

Create New Account
help
Wise for Visual Studio.NET Wise for Visual Studio.NET By Peter A. Bromberg, Ph.D. To "Print This Page" Link Peter Bromberg Wise for Visual Studio .NET is a total and complete installation development system for creating and editing Windows® Installer
Visual Studio .net .NET Framework Hi NG, ich habe vor längerer Zeit mit Visual Studio .Net 2003 gearbeitet und überlege momentan auf einen neueren Stand upzudaten. Ein Visual Studio .Net 2008 scheint es nicht zu geben. Habe zumindest mit googeln nichts gefunden. Was
Visual Studio versioning . . . . how to tell? .NET Framework To my knowledge, Visual studio 6 was released in 1998, then Visual Studio .NET 2002 is VS 7, then Visual Studio .NET 2003 is VS 7.1, then Visual
visual studio.net 2003 and Access 2007 database .NET Framework Hi I am currently using Visual Studio.Net 2003 running on Windows Server 2000 operating system. I have used Visual Studio.net 2003 connecting to Access 2002 databases in the pass with great success. Now
Is Visual Studio self-hosting ? .NET Framework Does Microsoft use Visual Studio IDE, Visual Studio Debugger, Visual Studio Linker and Visual Studio compiler for developing Visual Studio ? Or is Visual Studio not