zoukankan      html  css  js  c++  java
  • asp.net 异步动态加载控件

    最近有个项目用到,研究了下,基本成型,记于此。
    需求:根据输入信息的不同,结合用户配置,加载不同的多个视图,形成Tab页,并异步加载数据。视图使用UserControl 可视化制作。
    基本思路:
    1. 先生成Tab页,在视图区域先加载一个Loading的图片。
    2. 页尾生成Callback脚本。
    3. App Code中,接收Callback方法调用,动态加载视图UserControl控件,Render到string中,返回到页面。
    4. 页面接收"html"内容,并替换视图区域的Loading图片,加载完毕。

    部分代码片段:
    1. Tab Control 作用了JQuery UI 的Tab,并以Asp.net控件形式封装。
    Code

    2. 将Callback部分,封装成CallbackPlaceHolder,可动态加裁任意用户控件。
    Code

    3. 动态加裁UserControl.
    // view = "~/Views/DataGridView.ascx"                     
    IView control = (IView)LoadControl(view);
    control.ViewInfo 
    = viewInfo;
    this.TabWorkspaceMain.Show(control, viewInfo.SmartPartInfo);

    4. 加载数据事,将UserControl Render到string.
    Code

    5. 最后,结合之前在页面上生成的javascript脚本,将内容显示。
                        function ClientCallback_PlaceHolder_xxx(result, context)
                        {
                            $(
    '#callback_placeholder_xxx').html(result);
                        }
  • 相关阅读:
    严蔚敏数据结构习题3.14
    Effective C++ Item 34 Differentiate between inheritance of interface and inheritance of implementation
    Effective C++ Item 33 Avoid hiding inherited names
    Effective C++ Item 19 Treat class design as type design
    Effective C++ Item 18 Make interfaces easy to use correctly and hard to use incorrectly
    Effective C++ Item 17 Store newed objects in smart pointer in standalone statements
    Effective C++ Item 16 Use the same form in corresponding uses of new and delete
    Effective C++ Item 15 Provide access to raw resources in resource-managing classes
    Effective C++ Item 14 Think carefully about copying behavior in resource-managing classe
    Effective C++ Item 13 Use object to manage resources
  • 原文地址:https://www.cnblogs.com/zhongzf/p/1560098.html
Copyright © 2011-2022 走看看