Feeds:
Posts
Comments

Archive for the ‘AjaxControlToolkit’ Category

In web application accordion is a very nice using. By using that you can make you website good looking and in a small space you cam put many things. Here am giving you example of a dynamic Accordion which i am loading from a XML file.

Dynamic accordion from xmlTo create that using AjaxControlToolkit. In AjaxControlToolkit a control named Accordion is available , i have just load this dynamically and reading data from XML.
Here are the coder to read data from XML and Load accordion dynamically

Accordion accordion = new Accordion();
accordion.ID = “AccordionID”;
accordion.SelectedIndex = 0;
accordion.FadeTransitions = true;
accordion.FramesPerSecond = 50;
accordion.TransitionDuration = 250;
accordion.SuppressHeaderPostbacks = true;
string _path = HttpContext.Current.Server.MapPath(@”Sitemap.xml”);
FileStream stream = new FileStream(_path, FileMode.Open , FileAccess.Read, FileShare.ReadWrite);
XmlDocument document = new XmlDocument();
document.Load(stream);
XmlNodeList nodeList = document.GetElementsByTagName(“Item”);
for (int i = 0; i < nodeList.Count; i++)
{
AccordionPane accorPane = new AccordionPane();
Label lbl = new Label();
lbl.ID = “lblControl”;
lbl.Text = nodeList[i].Attributes[“name”].Value;
lbl.Width = 200;
lbl.BackColor = System.Drawing.Color.Wheat;
lbl.Style.Add(HtmlTextWriterStyle.MarginBottom, “3px”);
accorPane.HeaderContainer.Controls.Add(lbl);
for (int j = 0; j < nodeList[i].ChildNodes.Count; j++)
{
string name = nodeList[i].ChildNodes[j].Attributes[“name”].Value;
Label lbl2 = new Label();
lbl2.ID = “lblControl2”;
lbl2.Text = name;
lbl2.Width = 195;
lbl2.BackColor = System.Drawing.Color.WhiteSmoke;
lbl2.Style.Add(HtmlTextWriterStyle.MarginBottom, “2px”);
lbl2.Style.Add(HtmlTextWriterStyle.PaddingLeft, “5px”);
HyperLink hl = new HyperLink();
accorPane.ContentContainer.Controls.Add(lbl2);
accorPane.ContentContainer.Controls.Add(new LiteralControl(“<br/>”));
}
accordion.Panes.Add(accorPane);
}
PlaceHolder1.Controls.Add(accordion);
stream.Close();

Advertisements

Read Full Post »

I was workign with a small application where i create Accordion runtime. I i got problem for that the problem was “The TargetControlID of ‘_AccordionExtender’ is not valid. The value cannot be null or empty”. I wrote codes like that

This code is not working for Accordion

Finally got the solution just add accordion.ID = “AccordionID” and this problem is solved. So the fixed code is look like that

Create Accordion at tuntime

Read Full Post »