コード例 #1
0
    private void LoadAndRenderControl()
    {
        WidgetConfig config = WidgetFactory.Instance.GetWidget(_controlId);

        if (null != config)
        {
            Control control = null;
            if (_hostFilterPopUp)
            {
                if (null != config.FilterWidget)
                {
                    control = this.LoadControl(config.FilterWidget.Path);
                    IFilterControl filterControl = control as IFilterControl;
                    if (null != filterControl)
                    {
                        filterControl.ApplyConfig(config.FilterWidget.FilterConfig);
                    }
                }
                else
                {
                    RenderNotFoundControl();
                }
            }
            else
            {
                control = this.LoadControl(config.Path);
            }

            if (null != control)
            {
                // check if the control is a query broker consumer
                IQueryableControl qryControl = control as IQueryableControl;
                if (null != qryControl)
                {
                    IQueryBroker broker = config.GetQueryBroker();

                    // check if we are in filter post back
                    if (_isFilterPostback)
                    {
                        FilterInfo info = FilterInfo.ExtractFrom(Request.Form);
                        broker.ApplyFilter(info);
                    }

                    ITable tableQuery = broker.TableSelect;
                    qryControl.SetTableSelect(tableQuery);
                }

                RenderHostedControl(control);
            }
            else
            {
                RenderNotFoundControl();
            }
        }
        else
        {
            RenderNotFoundControl();
        }
    }