Ejemplo n.º 1
0
 /// <summary>
 /// Load a webforms view (Page, UserControl, MasterPage) from the given virtual path.
 /// </summary>
 /// <param name="virtualPath"></param>
 /// <returns></returns>
 public static Control LoadControlFromVirtualPath(string virtualPath)
 {
     // We're using LoadControl of an arbitrary UserControl to load the view. We could also use the BuildManager, but
     // in that case, the control hierarchy appears to be empty and thus, pretty useless.
     UserControl controlLoader = new UserControl();
     return controlLoader.LoadControl(virtualPath);
 }
Ejemplo n.º 2
0
		bool UserControl { get { return !string.IsNullOrEmpty(Path); } } // we must load a UserControl

		protected override void OnInit(EventArgs e) {
			try {
				if (UserControl) {
					var userControl = new UserControl();
					LoadedControl = userControl.LoadControl(Path);
				}
			} catch { }
			base.OnInit(e);
		}
Ejemplo n.º 3
0
        public void LoadControlInDiv(IPanelArgs args, bool enableEdit, PSCPanel pannel)
        {
            //Create Div Edit

            if (enableEdit)
            {
                PSCPanel divEdit = new PSCPanel();
                divEdit.ID       = string.Format("psc-divPanel{0}-edit", _panel.ToString());
                divEdit.CssClass = "psc-divPanelEdit";
                pannel.Controls.Add(divEdit);

                //Title Pannel
                System.Web.UI.WebControls.Literal lblTitle = new System.Web.UI.WebControls.Literal();
                lblTitle.Text = string.Format("<span>{0}</span>", _panel.Name);
                divEdit.Controls.Add(lblTitle);

                //Button Edit
                System.Web.UI.WebControls.Literal btnEditApperance = new System.Web.UI.WebControls.Literal();
                btnEditApperance.Text = string.Format("<img id='{0}_btnEditApperance' title='Hiệu chỉnh Panel' src='/Systems/Engine/Images/PortletEditApperance.png' alt='Edit Apperance' onclick='PanelStyleGet(\"{0}\");'/>", _panel.Id, _panel.Id);
                divEdit.Controls.Add(btnEditApperance);

                //Button Remove
                System.Web.UI.WebControls.Literal btnRemove = new System.Web.UI.WebControls.Literal();
                btnRemove.Text = string.Format("<img id='{0}_btnRemove'  title='Xóa Panel' src='/Systems/Engine/Images/PortletDelete.png' alt='Remove Panel' onclick='PanelRemove(\"{1}\");'/>", _panel.Id, _panel.Id);
                divEdit.Controls.Add(btnRemove);
            }

            PSCPanel divContent = new PSCPanel();

            divContent.ID          = string.Format("psc-divPanel{0}-Content", _panel.ToString());
            divContent.Style.Value = "min-height: 30px;";
            pannel.Style.Value     = _style;
            pannel.Controls.Add(divContent);

            //Load Porlets into divContent
            if (args != null)
            {
                System.Web.UI.UserControl uc = new System.Web.UI.UserControl();
                divContent.Controls.Add(uc.LoadControl(args.Path));
            }
            else
            {
                foreach (PortletInstanceInPanel item in _portlets)
                {
                    //divContent.Controls.Add(item.RenderTable(enableEdit));


                    //Create div Portlet Wrapper
                    PSCPanel divPortletWrapper = new PSCPanel();
                    divPortletWrapper.ID          = string.Format("psc-divPortlet-{0}", item.PortletInstance.Id.ToString());
                    divPortletWrapper.Style.Value = item.Style;
                    divPortletWrapper.CssClass    = "psc-divPortlet-Wrapper";
                    divContent.Controls.Add(divPortletWrapper);

                    // Create div Portlet Header
                    if (enableEdit)
                    {
                        CreateDivPortletHeader(divPortletWrapper, item);
                    }

                    // Create div Portlet Content
                    PSCPanel divPortletContent = new PSCPanel();
                    //divPortletContent.ID = string.Format("psc-divPortlet-{0}", item.PortletInstance.Id.ToString());
                    divPortletContent.CssClass = "psc-divPortlet-Content";
                    divPortletWrapper.Controls.Add(divPortletContent);

                    divPortletContent.Controls.Add(item.RenderPortletDiv(enableEdit));
                }
            }
        }
Ejemplo n.º 4
0
        public System.Web.UI.Control LoadControlInTable(IPanelArgs args, bool enableEdit)
        {
            PSCPanel result = new PSCPanel();

            result.ID = string.Format("pn{0}", _panel.ToString());
            PSCPanel pnTitle = new PSCPanel();

            pnTitle.ID = string.Format("pn{0}Title", _panel.ToString());

            System.Web.UI.WebControls.Table tblTitle = new System.Web.UI.WebControls.Table();
            tblTitle.CellPadding = 0;
            tblTitle.CellSpacing = 0;
            tblTitle.Width       = System.Web.UI.WebControls.Unit.Percentage(100);
            System.Web.UI.WebControls.TableRow rowTitle = new System.Web.UI.WebControls.TableRow();
            tblTitle.Rows.Add(rowTitle);
            System.Web.UI.WebControls.TableCell cellLeft = new System.Web.UI.WebControls.TableCell();
            System.Web.UI.WebControls.Image     imgLeft  = new System.Web.UI.WebControls.Image();
            imgLeft.ImageUrl = "~/Systems/Engine/Images/PanelTitleLeft.png";
            cellLeft.Controls.Add(imgLeft);
            cellLeft.Width  = System.Web.UI.WebControls.Unit.Pixel(18);
            cellLeft.Height = System.Web.UI.WebControls.Unit.Pixel(18);
            rowTitle.Cells.Add(cellLeft);

            System.Web.UI.WebControls.TableCell cellTitle = new System.Web.UI.WebControls.TableCell();
            cellTitle.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            System.Web.UI.WebControls.Label lblTitle = new System.Web.UI.WebControls.Label();
            lblTitle.Text = _panel.Name;
            cellTitle.Controls.Add(lblTitle);
            cellTitle.Style.Add(System.Web.UI.HtmlTextWriterStyle.BackgroundImage, "/Systems/Engine/Images/PanelTitleCenter.png");
            rowTitle.Cells.Add(cellTitle);


            System.Web.UI.WebControls.TableCell cellControls = new System.Web.UI.WebControls.TableCell();
            cellControls.Wrap = false;
            cellControls.Style.Add(System.Web.UI.HtmlTextWriterStyle.BackgroundImage, "/Systems/Engine/Images/PanelTitleCenter.png");

            System.Web.UI.WebControls.Literal btnEditApperance = new System.Web.UI.WebControls.Literal();
            btnEditApperance.Text = string.Format("<img id='{0}_btnEditApperance' src='/Systems/Engine/Images/PanelEditApperance.png' alt='Edit Apperance' onclick='PanelStyleGet(\"{0}\");'/>", _panel.Id, _panel.Id);
            cellControls.Controls.Add(btnEditApperance);

            if (_panel.Id != (int)Panel.PANEL.Center)
            {
                System.Web.UI.WebControls.Literal btnRemove = new System.Web.UI.WebControls.Literal();
                btnRemove.Text = string.Format("<img id='{0}_btnRemove' src='/Systems/Engine/Images/PanelDelete.png' alt='Remove Panel' onclick='PanelRemove(\"{1}\");'/>", _panel.Id, _panel.Id);
                cellControls.Controls.Add(btnRemove);
            }
            rowTitle.Cells.Add(cellControls);

            System.Web.UI.WebControls.TableCell cellRight = new System.Web.UI.WebControls.TableCell();
            System.Web.UI.WebControls.Image     imgRight  = new System.Web.UI.WebControls.Image();
            imgRight.ImageUrl = "~/Systems/Engine/Images/PanelTitleRight.png";
            cellRight.Controls.Add(imgRight);
            rowTitle.Cells.Add(cellRight);

            //bool enableEdit = true;
            if (enableEdit)
            {
                result.Controls.Add(pnTitle);
            }

            pnTitle.Controls.Add(tblTitle);

            PSCPanel pnMain = new PSCPanel();

            pnMain.ID          = string.Format("pn{0}Display", _panel.ToString());
            pnMain.Style.Value = _style;
            //add panel class for mobile
            pnMain.CssClass = "panelCss";
            if (pnMain.Style["width"] != null)
            {
                pnTitle.Width = System.Web.UI.WebControls.Unit.Parse(pnMain.Style["width"]);
            }

            if (args != null)
            {
                pnMain.Height = System.Web.UI.WebControls.Unit.Empty;
            }

            result.Controls.Add(pnMain);
            if (enableEdit)
            {
                pnMain.BorderStyle = System.Web.UI.WebControls.BorderStyle.Dotted;
                pnMain.BorderWidth = 1;
            }

            if (args != null)
            {
                System.Web.UI.UserControl uc = new System.Web.UI.UserControl();
                pnMain.Controls.Add(uc.LoadControl(args.Path));
            }
            else
            {
                foreach (PortletInstanceInPanel item in _portlets)
                {
                    pnMain.Controls.Add(item.RenderPortletTable(enableEdit));
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds the component to dealer product group.
        /// </summary>
        /// <param name="componentPath">The component path.</param>
        /// <param name="targetControlName">Name of the target control.</param>
        /*private void AddComponentToDealerProductGroup(string componentPath, string targetControlName)
        {
          if (!string.Equals(Sitecore.Context.GetSiteName(), "dealer") || !Sitecore.Context.Item.IsItemOfType(Consts.ProducGroupTemplateId))
          {
        return;
          }

          this.AddComponent(componentPath, targetControlName);
        }*/
        /// <summary>
        /// Adds the component cart to product on dealer site.
        /// </summary>
        /// <param name="componentPath">The component path.</param>
        /// <param name="targetControlName">Name of the target control.</param>
        /*private void AddComponentToDealerProduct(string componentPath, string targetControlName)
        {
          if (!string.Equals(Sitecore.Context.GetSiteName(), "dealer") || !Sitecore.Context.Item.IsItemOfType(Consts.ProducBaseTemplateId))
          {
        return;
          }

          this.AddComponent(componentPath, targetControlName);
        }*/
        /// <summary>
        /// Adds the component.
        /// </summary>
        /// <param name="componentPath">The component path.</param>
        /// <param name="targetControlName">Name of the target control.</param>
        private void AddComponent(string componentPath, string targetControlName)
        {
            var rightColumn = this.GetControl(this.Page, targetControlName);
              if (rightColumn == null)
              {
            return;
              }

              var temp = new UserControl();
              var ctrl = temp.LoadControl(componentPath);
              Assert.IsNotNull(ctrl, string.Format("Failed to load control '{0}'", componentPath));
              rightColumn.Controls.AddAt(0, ctrl);
        }