简体   繁体   English

使用Ajax Control Toolkit,我将如何以编程方式创建可在运行时调整大小并可拖放的折叠控制?

[英]With the Ajax Control Toolkit, how would I go about programmatically creating an accordion control that is resizeable and drag/droppable at runtime?

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. 我有一个按钮,OnClick,应该创建手风琴。 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. 然后将整个手风琴添加到Ajax面板。 My event handler follows. 我的事件处理程序如下

    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 感谢帮助

Dynamically added controls are typically supposed to be added during init or preinit event of the page. 动态添加的控件通常应该在页面的init或preinit事件期间添加。 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. 关键是要确保手风琴客户端上的$register方法正在发生。 This is what initializes the client-side features of the AJAX component, and starts the lifecycle. 这是初始化AJAX组件的客户端功能,并启动生命周期。 I don't know if it happens for dynamically added controls... 我不知道动态添加的控件是否会发生......

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交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM