예제 #1
0
        /// <summary>
        /// Use the PreRender event to set the page title and stylesheet. These are properties of the page control
        /// which is at position 0 in the controls collection.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            BasePageControl pageControl = (BasePageControl)Controls[0];

            // Set the stylesheet and title properties
            if (_css == null)
            {
                _css = ResolveUrl(ConfigurationSettings.AppSettings["DefaultCss"]);
            }
            if (_title == null)
            {
                _title = ConfigurationSettings.AppSettings["DefaultTitle"];
            }
            pageControl.Title = _title;
            pageControl.Css   = _css;
            // Kien them vao de support mot so control Ajax
            base.OnPreRender(e);
        }
예제 #2
0
        protected override void OnInit(EventArgs e)
        {
            // Init
            PlaceHolder       plc = null;
            ControlCollection col = Controls;

            // Set template directory
            if (_templateDir == null && ConfigurationSettings.AppSettings["TemplateDir"] != null)
            {
                _templateDir = ConfigurationSettings.AppSettings["TemplateDir"];
            }

            // Get the template control
            if (_templateFilename == null)
            {
                _templateFilename = ConfigurationSettings.AppSettings["DefaultTemplate"];
            }
            BasePageControl pageControl = (BasePageControl)LoadControl(ResolveUrl(_templateDir + _templateFilename));

            // Add the pagecontrol on top of the control collection of the page
            pageControl.ID = "p";
            col.AddAt(0, pageControl);

            // Get the Content placeholder
            plc = pageControl.Content;
            if (plc != null)
            {
                // Iterate through the controls in the page to find the form control.
                foreach (Control control in col)
                {
                    if (control is HtmlForm)
                    {
                        // We've found the form control. Now move all child controls into the placeholder.
                        HtmlForm formControl = (HtmlForm)control;
                        while (formControl.Controls.Count > 0)
                        {
                            // Updated 10/04/2008: Support UpdatePanel by Kien
                            if (formControl.Controls[0] is UpdatePanel)
                            {
                                UpdatePanel updatepanel = new UpdatePanel();
                                UpdatePanel oldPanel    = (UpdatePanel)formControl.Controls[0];
                                while (oldPanel.ContentTemplateContainer.Controls.Count > 0)
                                {
                                    updatepanel.ContentTemplateContainer.Controls.Add(
                                        oldPanel.ContentTemplateContainer.Controls[0]);
                                }
                                plc.Controls.Add(updatepanel);
                                formControl.Controls.RemoveAt(0);
                            }
                            else
                            {
                                plc.Controls.Add(formControl.Controls[0]);
                            }
                        }
                    }
                }
                // throw away all controls in the page, except the page control
                while (col.Count > 1)
                {
                    col.Remove(col[1]);
                }
            }
            base.OnInit(e);
        }