使用Ajax Control Toolkit,我将如何以编程方式创建可在运行时调整大小和拖放的手风琴控件?

时间:2022-06-25 16:06:33

I was trying to generate a resizable and drag/droppable ajax control toolkit accordion control programmatically, but am running into some problems.

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

First, can it be done?

首先,可以做到吗?

Second, my approach is not exactly working. I have a button that, OnClick, is supposed to create the accordion. So I create the accordion. Add an accordion pane to it. Add a combo button to the accordion pane. Then add the entire accordion to the Ajax Panel. My event handler follows.

其次,我的方法并不完全正常。我有一个按钮,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();
    }

What I get when I press the test button is what appears to be a minimized button without text generated under the test button. I have no clue what to do.

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

Appreciate the help

感谢帮助

2 个解决方案

#1


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.

动态添加的控件通常应该在页面的init或preinit事件期间添加。这可能是一个复杂因素,因为你是在加载后这样做的。

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...

关键是要确保手风琴客户端上的$ register方法正在发生。这是初始化AJAX组件的客户端功能,并启动生命周期。我不知道它是否适用于动态添加的控件......

#2


1  

You may want to look at the JQuery UI Accordian widget and use the draggable/droppable interactions.

您可能希望查看JQuery UI Accordian小部件并使用draggable / droppable交互。

You could use server side code to create an block and apply the jQuery interaction.

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

#1


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.

动态添加的控件通常应该在页面的init或preinit事件期间添加。这可能是一个复杂因素,因为你是在加载后这样做的。

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...

关键是要确保手风琴客户端上的$ register方法正在发生。这是初始化AJAX组件的客户端功能,并启动生命周期。我不知道它是否适用于动态添加的控件......

#2


1  

You may want to look at the JQuery UI Accordian widget and use the draggable/droppable interactions.

您可能希望查看JQuery UI Accordian小部件并使用draggable / droppable交互。

You could use server side code to create an block and apply the jQuery interaction.

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