0

我试图以编程方式生成一个可调整大小和可拖放的 ajax 控件工具包手风琴控件,但遇到了一些问题。

首先,能做到吗?

其次,我的方法并不完全奏效。我有一个按钮,OnClick,应该用来创建手风琴。所以我创造了手风琴。向它添加一个手风琴窗格。将组合按钮添加到手风琴窗格。然后将整个手风琴添加到 Ajax 面板。我的事件处理程序如下。

    protected void btnTest_Clicked(object sender, EventArgs e)
    {
        //Generate the accordion
        AjaxControlToolkit.Accordion acc = new AjaxControlToolkit.Accordion();

        //Generate a single accordion pane
        AjaxControlToolkit.AccordionPane itm = new AccordionPane();

        //Create and add a control to the pane
        AjaxControlToolkit.ComboBoxButton cbbtn = new ComboBoxButton();
        itm.Controls.Add(cbbtn);   
        acc.Panes.Add(itm);

        //Add resizable extender to the accordion.  Only did resizable for now.
        //One step at a time.
        AjaxControlToolkit.ResizableControlExtender extResizeLocation = new AjaxControlToolkit.ResizableControlExtender();
        extResizeLocation.TargetControlID = acc.ID;
        extResizeLocation.Enabled = true;

        //Add accordion to update panel and update.
        UpdatePanel1.Controls.Add(acc);
        UpdatePanel1.Update();
    }

当我按下测试按钮时,我得到的似乎是一个最小化的按钮,在测试按钮下没有生成文本。我不知道该怎么做。

感谢帮助

4

2 回答 2

1

Dynamically added controls are typically supposed to be added during init or preinit event of the page. That may be a complication, since you are doing it after load.

The key is to make sure the $register method on the client for the accordion is occurring. This is what initializes the client-side features of the AJAX component, and starts the lifecycle. I don't know if it happens for dynamically added controls...

于 2013-01-03T19:39:57.887 回答
1

您可能想查看JQuery UI Accordian小部件并使用可拖放交互。

您可以使用服务器端代码创建一个块并应用 jQuery 交互。

于 2013-01-03T19:47:46.780 回答