Dropthings 和加载用户控制内容

发布于 2024-10-07 02:25:10 字数 197 浏览 0 评论 0原文

我开始查看 dropthings 门户,但我不明白小部件中的内容是如何加载的。我的理解是,标题位于 Updatepanel 中,小部件的主体位于 UpdatePanel 中,其中包含 ASP 面板。加载页面时,首先加载所有小部件的 ASP 面板,然后再加载面板中的用户控件。

有人可以解释这是如何发生的并指出我设置此设置的代码吗?

任何帮助表示赞赏

I started looking at the dropthings portal and I don't understand how the content within the widget gets loaded. My understanding is that the header is in an Updatepanel and the body of the widget is in an UpdatePanel with a ASP Panel in it. When the page loads, the ASP Panels of all the widgets load first before loading the User controls within the panels.

Can someone explain how this happens and point me to the code where this is setup?

Any help is appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不及他 2024-10-14 02:25:10

我使用的是 2.7.5 版本(1 月 11 日发布),所以这可能有点新。

每个小部件都是一个用户控件,并托管在 WidgetContainer.ascx 中。 WidgetContainer 提供了所有常用功能,如标题重命名、定位、展开/折叠、编辑等。源文件位于根“dropthings”文件夹中。查看 Init 方法,我们可以看到 UserControl 实例化的位置&添加到页面:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);

    var widget = LoadControl(this.WidgetInstance.Widget.Url);  //Here's the magic
    widget.ID = "Widget" + this.WidgetInstance.Id.ToString();

    WidgetBodyPanel.Controls.Add(widget);
    _WidgetRef = widget as IWidget;
    if (_WidgetRef != null) _WidgetRef.Init(this);        
}

因此,首先将 WidgetContainer 添加到配置的每个 Widget 的控件树中。然后,在初始化每个容器时,它会创建特定的 UserControl,然后将其添加到页面。当

    WidgetBodyPanel.Controls.Add(widget);

被调用时,它将初始化(OnInit)特定的小部件。从那里开始,小部件的内容就掌握在它自己的手中。

I'm using version 2.7.5 (released Jan 11), so this might be a bit newer.

Each widget is a user control, and is hosted in a WidgetContainer.ascx. The WidgetContainer provides all the common functions like the title renaming, positioning, expand/collapse, editing, etc. The source file is in the root "dropthings" folder. Looking at the Init method, we can see where the UserControl instantiated & added to the page:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);

    var widget = LoadControl(this.WidgetInstance.Widget.Url);  //Here's the magic
    widget.ID = "Widget" + this.WidgetInstance.Id.ToString();

    WidgetBodyPanel.Controls.Add(widget);
    _WidgetRef = widget as IWidget;
    if (_WidgetRef != null) _WidgetRef.Init(this);        
}

So, first the WidgetContainer is added to the control tree for each Widget configured. Then as each container is initialized, it creates then adds the specific UserControl to the page. When

    WidgetBodyPanel.Controls.Add(widget);

is called, it will initialize (OnInit) the specific widget. From there the contents of the widget are in it's own hands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文