firstly make sure you have gone through the following list of prerequisites and notes:
Brief overview of requirements for using Ajax with Sharepoint 2007 web parts
- You have to make sure you programmatically create the control in the web part codebehind. Do it in the method "protected override void CreateChildControls()"
- Define the control as a global variable:
Accordion Accordion1; - Initialise the control in the CreateChildControls() method
Accordion1 = new Accordion(); - Make sure you give it an ID
Accordion1.ID = "Accordion1"; - Set the selected index
Accordion1.SelectedIndex = 0; - Set other properties such as FadeTransitions and TransitionDuration etc
Accordion1.FadeTransitions = true;
Accordion1.FramesPerSecond = 20;
Accordion1.TransitionDuration = 100;
Accordion1.AutoSize = AutoSize.none; - Add the accordion control to the page's controls collection
this.Controls.Add(Accordion1) (note: this still takes place in the CreateChildControls() method) - Add panes in the following way:
AccordionPane pane1 = new AccordionPane()
string header = "this is the pane header";
pane1.HeaderContainer.Controls.Add(new LiteralControl(header);
string content = "this is the pane content";
pane1.ContentContainer.Controls.Add(new LiteralControl(content));
Accordion1.Panes.Add(pane1); - Remember that the following line of code must ALWAYS be at the end of the CreateChildControls() method:
base.CreateChildControls(); - In your web part's Render(HtmlTextWriter writer) method
add the following at the location where you want the control to be displayed:
this.Accordion1.RenderControl(writer);
2 comments:
Thanks for the article.
Amazing Article, Incredible writing style. i really liked the way you represent the content.
Sharepoint Development | Asp.net Development
Post a Comment