需求:根据输入信息的不同,结合用户配置,加载不同的多个视图,形成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控件形式封装。
Page.Header.Controls.Add(function_script);
}
2. 将Callback部分,封装成CallbackPlaceHolder,可动态加裁任意用户控件。
}
3. 动态加裁UserControl.
// view = "~/Views/DataGridView.ascx"
IView control = (IView)LoadControl(view);
control.ViewInfo = viewInfo;
this.TabWorkspaceMain.Show(control, viewInfo.SmartPartInfo);
IView control = (IView)LoadControl(view);
control.ViewInfo = viewInfo;
this.TabWorkspaceMain.Show(control, viewInfo.SmartPartInfo);
4. 加载数据事,将UserControl Render到string.
}
5. 最后,结合之前在页面上生成的javascript脚本,将内容显示。
function ClientCallback_PlaceHolder_xxx(result, context)
{
$('#callback_placeholder_xxx').html(result);
}
{
$('#callback_placeholder_xxx').html(result);
}