문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top