动态创建AJAX控件手风琴 [英] Dynamically Creating AJAX Accordian Controls
问题描述
我想在页面加载创建手风琴Controlls Dynammically,code明智的,这是我迄今为止:
I'm trying to create Accordian Controlls Dynammically on Page Load, code wise this is what I have so far:
// Create dynamic acordian control
AjaxControlToolkit.Accordion info = new AjaxControlToolkit.Accordion();
AjaxControlToolkit.AccordionPane infoPane = new AjaxControlToolkit.AccordionPane();
info.ID = hostelId;
info.FadeTransitions = true;
info.FramesPerSecond = 10;
info.TransitionDuration = 500;
Literal headerContent = new Literal();
headerContent.ID = hostelId + "_Header";
headerContent.Text = hostelName + " More Info ";
Literal content = new Literal();
content.ID = hostelId + "_Content";
content.Text = hostelName + " BOOM ";
infoPane.HeaderContainer.Controls.Add(headerContent);
infoPane.ContentContainer.Controls.Add(content);
info.Panes.Add(infoPane);
cell3.Controls.Add(info);
当我运行页面时,contente的手风琴控制显示器,但它只是文本,而不是实际的手风琴。只是想知道,如果有人能在正确的方向指向我。
When I run the page, the contente for the Accordian control displays, but its just text and not the actual accordian. Just wondering if someone can point me in the right direction.
推荐答案
我猜你也需要添加手风琴
到的ScriptManager
您的网页上。
I'm guessing you also need to add the Accordion
to the ScriptManager
on your page.
scriptManager.Controls.Add(info);
另外,你尝试过在其他事件处理程序添加控件?它seeems的初始化
是你应该动态地至少根据的这个Microsoft支持页面。 (我不记得在那里我已经在我的web应用程序做它,但初始化
听起来右)。
Also, have you tried adding the control in another event handler? It seeems that Init
is the event on which you should dynamically be adding controls, at least according to this Microsoft Support page. (I can't remember where I've done it in my web applications, but Init
would sound right.)
希望有所帮助。
这篇关于动态创建AJAX控件手风琴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!