Esempio n. 1
0
        protected override void CreateChildControls()
        {
            Controls.Clear();

            rptList   = new Repeater();
            plhHeader = new WebPlaceHolder();
            plhFooter = new WebPlaceHolder();

            if (ItemTemplate != null)
            {
                rptList.ItemTemplate = ItemTemplate;
            }
            if (AlternatingItemTemplate != null)
            {
                rptList.ItemTemplate = AlternatingItemTemplate;
            }
            if (SeparatorTemplate != null)
            {
                rptList.SeparatorTemplate = SeparatorTemplate;
            }

            PopulateListControls();

            if (HeaderTemplate != null)
            {
                HeaderTemplate.InstantiateIn(plhHeader);
            }
            if (FooterTemplate != null)
            {
                FooterTemplate.InstantiateIn(plhFooter);
            }

            rptList.ItemCreated   += ListItemCreated;
            rptList.ItemDataBound += ListItemDataBound;
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // header
            if (HeaderTemplate != null)
            {
                _headerTemplate = new HtmlGenericControl("header");
                _headerTemplate.Attributes.Add("class", "modal-header");
                HtmlGenericControl h2 = new HtmlGenericControl("h2");
                h2.Attributes.Add("class", "modal-title");
                _headerTemplate.Controls.Add(h2);
                this.Controls.Add(_headerTemplate);
                HeaderTemplate.InstantiateIn(h2);
            }

            // body with empty content by default
            _bodyTemplate = new HtmlGenericControl("div");
            _bodyTemplate.Attributes.Add("class", "modal-body");
            this.Controls.Add(_bodyTemplate);
            if (BodyTemplate != null)
            {
                BodyTemplate.InstantiateIn(_bodyTemplate);
            }

            // footer
            if (FooterTemplate != null)
            {
                _footerTemplate = new HtmlGenericControl("div");
                _footerTemplate.Attributes.Add("class", "modal-footer");
                this.Controls.Add(_footerTemplate);
                FooterTemplate.InstantiateIn(_footerTemplate);
            }

            try
            {
                Control target = Page.FindControlRecursive(this.AssociateControlID);

                if (target is WebControl wc)
                {
                    wc.Attributes["href"] = "#" + this.ClientID;
                    wc.AddCssClass(IsClosable ? "wb-lbx" : "wb-lbx lbx-modal");
                }
            }
            catch (Exception)
            {
                throw new Exception("AssociateControlID property for WetModal with ID " + this.ID + " should refer to an html control with the href attribute.");
            }
        }
        public override void RenderFooter(TableCell container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (FooterTemplate == null)
            {
                base.RenderFooter(container);
            }
            else
            {
                FooterTemplate.InstantiateIn(container);
                container.ApplyStyle(FooterStyle);
            }
        }
Esempio n. 4
0
        private void CreateControlHierarchy()
        {
            if (HeaderTemplate != null)
            {
                BasicTemplateContainer header = new BasicTemplateContainer();
                HeaderTemplate.InstantiateIn(header);
                Controls.Add(header);
                Controls.Add(new LiteralControl("<br>"));
            }

            int count = menuData.Count;

            for (int index = 0; index < count; index++)
            {
                MenuItemData itemdata = (MenuItemData)menuData[index];
                CreateMenuItem(itemdata.Title, itemdata.Url, itemdata.ImageUrl, itemdata.Target);

                if (index != count - 1)
                {
                    if (SeparatorTemplate != null)
                    {
                        BasicTemplateContainer separator = new BasicTemplateContainer();
                        SeparatorTemplate.InstantiateIn(separator);
                        Controls.Add(separator);
                    }
                    else
                    {
                        Controls.Add(new LiteralControl(" | "));
                    }
                }
            }

            if (FooterTemplate != null)
            {
                Controls.Add(new LiteralControl("<br>"));
                BasicTemplateContainer footer = new BasicTemplateContainer();
                FooterTemplate.InstantiateIn(footer);
                Controls.Add(footer);
            }
        }
        /// <summary>
        /// Creates the child controls in a control derived from System.Web.UI.WebControls.CompositeControl.
        /// </summary>
        protected override void CreateChildControls()
        {
            Controls.Clear();

            IntializeControlsDefaultValues();

            /********************************/
            /******** CREATE CONTROLS *******/
            /********************************/



            //*********************//
            //*** USE TEMPLATES ***//
            //*********************//


            //outer box
            string style = string.Empty;

            style = "shopping_cart";

            Controls.Add(new LiteralControl("<table style='width: 100%' cellpadding='0' cellspacing='0' border='0'>"));
            Controls.Add(new LiteralControl("  <tr>"));

            Controls.Add(new LiteralControl("    <td class=\"" + style + "\" >"));


            //if the page developer does not explicitly add a <HeaderTemplate> tag
            //in ShoppingCartControl's declarative syntax
            if (HeaderTemplate == null)
            {
                if (this.DesignMode)
                {
                    ITemplate defaultTemplate = new MobileDefaultHeaderTemplate("Product", "Quantity", "SubTotal", "Delete");
                    defaultTemplate.InstantiateIn(this);
                }
                else
                {
                    if (this.DataSource != null)
                    {
                        CartItemCollection cic = this.DataSource;
                        if (cic.Count != 0)
                        {
                            ITemplate defaultTemplate = new MobileDefaultHeaderTemplate("Product", "Quantity", "SubTotal", "Delete");
                            defaultTemplate.InstantiateIn(this);
                        }
                        else
                        {
                            Topic     emptyCartTopic  = new Topic(this.EmptyCartTopicName);
                            ITemplate defaultTemplate = new MobileDefaultHeaderTemplate(emptyCartTopic.Contents);
                            defaultTemplate.InstantiateIn(this);
                        }
                    }
                    else
                    {
                        ITemplate defaultTemplate = new MobileDefaultHeaderTemplate("Product", "Quantity", "SubTotal", "Delete");
                        defaultTemplate.InstantiateIn(this);
                    }
                }
            }
            else
            {
                if (this.DataSource != null)
                {
                    CartItemCollection cic = (CartItemCollection)this.DataSource;
                    if (cic.Count != 0)
                    {
                        CustomTemplate headerTemplateItem = new CustomTemplate();
                        headerTemplateItem.ID = "headerTemplateItem";
                        HeaderTemplate.InstantiateIn(headerTemplateItem);

                        Controls.Add(new LiteralControl("      <table style='width : 100%;' cellpadding='0' cellspacing='0' border='0'>"));
                        Controls.Add(new LiteralControl("        <tr>"));
                        Controls.Add(new LiteralControl("          <td>"));
                        Controls.Add(headerTemplateItem);
                        Controls.Add(new LiteralControl("          </td>"));
                        Controls.Add(new LiteralControl("        </tr>"));
                        Controls.Add(new LiteralControl("      </table>"));
                    }
                    else
                    {
                        Topic     emptyCartTopic  = new Topic(this.EmptyCartTopicName);
                        ITemplate defaultTemplate = new MobileDefaultHeaderTemplate(emptyCartTopic.Contents);
                        defaultTemplate.InstantiateIn(this);
                    }
                }
                else
                {
                    CustomTemplate headerTemplateItem = new CustomTemplate();
                    headerTemplateItem.ID = "headerTemplateItem";
                    HeaderTemplate.InstantiateIn(headerTemplateItem);

                    Controls.Add(new LiteralControl("      <table style='width : 100%;' cellpadding='0' cellspacing='0' border='0'>"));
                    Controls.Add(new LiteralControl("        <tr>"));
                    Controls.Add(new LiteralControl("          <td>"));
                    Controls.Add(headerTemplateItem);
                    Controls.Add(new LiteralControl("          </td>"));
                    Controls.Add(new LiteralControl("        </tr>"));
                    Controls.Add(new LiteralControl("      </table>"));
                }
            }

            ShoppingCart cart = null;

            //ITEMS Template
            if (DataSource != null)
            {
                Items.Clear();
                int alternateItem = 0;
                CartItemCollection sortedCartItemForMinicart = new CartItemCollection();
                sortedCartItemForMinicart = this.DataSource;


                Panel pnlItems = new Panel();
                pnlItems.ID       = "pnlCartItems";
                pnlItems.CssClass = "cart_items";

                foreach (CartItem cItem in sortedCartItemForMinicart)
                {
                    cart = cItem.ThisShoppingCart;
                    if (alternateItem > 0)
                    {
                        // alternating separator
                        pnlItems.Controls.Add(new LiteralControl("<div style='border-top: solid 1px #444444'></div>"));
                    }

                    item = new MobileShoppingCartControlItem(this.LineItemSettings);

                    item.CartItem    = cItem;
                    item.AllowEdit   = this.AllowEdit;
                    item.DisplayMode = this.DisplayMode;
                    if (cItem.ThisShoppingCart.CartType == CartTypeEnum.Deleted)
                    {
                        item.IsDeleted = true;
                    }
                    Items.Add(item);
                    pnlItems.Controls.Add(item);

                    alternateItem++;
                }

                Controls.Add(pnlItems);
            }

            if (DesignMode)
            {
                Controls.Add(new LiteralControl("<table style='width: 100%;' cellpadding='0' cellspacing='0' border='0'>"));

                Controls.Add(new LiteralControl("  <tr>"));

                //dummy line item description
                Controls.Add(new LiteralControl("    <td style='width:60%' valign='top'>"));
                Controls.Add(new LiteralControl("      <table style='width: 100%;' cellpadding='0' cellspacing='0' border='0'>"));

                Controls.Add(new LiteralControl("        <tr>"));
                Controls.Add(new LiteralControl("          <td>Product Name : Unbound</td>"));
                Controls.Add(new LiteralControl("        </tr>"));

                Controls.Add(new LiteralControl("        <tr>"));
                Controls.Add(new LiteralControl("          <td>SKU : Unbound</td>"));
                Controls.Add(new LiteralControl("        </tr>"));

                Controls.Add(new LiteralControl("        <tr>"));
                Controls.Add(new LiteralControl("          <td>Size : Unbound</td>"));
                Controls.Add(new LiteralControl("        </tr>"));

                Controls.Add(new LiteralControl("        <tr>"));
                Controls.Add(new LiteralControl("          <td>Color : Unbound</td>"));
                Controls.Add(new LiteralControl("        </tr>"));

                Controls.Add(new LiteralControl("      </table>"));
                Controls.Add(new LiteralControl("    </td>"));

                //dummy quantity & delete button
                TextBox txtQuantity = new TextBox();
                txtQuantity.Text = "Unbound";

                LinkButton lnkDelete = new LinkButton();
                lnkDelete.Text = "shoppingcart.cs.107".StringResource();

                Controls.Add(new LiteralControl("    <td style='width:15%' valign='top'>"));
                Controls.Add(txtQuantity);
                Controls.Add(lnkDelete);
                Controls.Add(new LiteralControl("    </td>"));

                //dummy extended price
                Controls.Add(new LiteralControl("    <td style='width:25%;' align='right' valign='top'>Unbound"));
                Controls.Add(new LiteralControl("    </td>"));

                Controls.Add(new LiteralControl("  </tr>"));


                Controls.Add(new LiteralControl("</table>"));
            }
            else
            {
                if (FooterTemplate == null)
                {
                    ITemplate defaultTemplate = new DefaulFooterTemplate();
                    defaultTemplate.InstantiateIn(this);
                }
                else
                {
                    CustomTemplate footerTemplateItem = new CustomTemplate();
                    footerTemplateItem.ID = "footerTemplateItem";
                    FooterTemplate.InstantiateIn(footerTemplateItem);

                    Controls.Add(new LiteralControl("<div>"));
                    Controls.Add(footerTemplateItem);
                    Controls.Add(new LiteralControl("</div>"));
                }
            }
            //end outer box
            Controls.Add(new LiteralControl("    </td>"));
            Controls.Add(new LiteralControl("  </tr>"));
            Controls.Add(new LiteralControl("</table>"));
        }
Esempio n. 6
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        uxMessagePlaceHolder.Controls.Clear();
        uxValidationSummaryPlaceHolder.Controls.Clear();
        uxValidationDenotePlaceHolder.Controls.Clear();
        uxLanguageControlPlaceHolder.Controls.Clear();
        uxButtonEventPlaceHolder.Controls.Clear();
        uxButtonCommandPlaceHolder.Controls.Clear();
        uxTopContentBoxPlaceHolder.Controls.Clear();
        uxFooterPlaceHolder.Controls.Clear();

        uxFilterPlaceHolder.Controls.Clear();
        uxPageNumberPlaceHolder.Controls.Clear();
        uxGridPlaceHolder.Controls.Clear();
        uxBottomContentBoxPlaceHolder.Controls.Clear();

        uxContentPlaceHolder.Controls.Clear();

        // Message.
        ContentContainer container = new ContentContainer();

        if (MessageTemplate != null)
        {
            MessageTemplate.InstantiateIn(container);
            uxMessagePlaceHolder.Controls.Add(container);
            uxMessagePlaceHolder.Visible = true;
        }
        else
        {
            uxMessagePlaceHolder.Controls.Add(new LiteralControl("No Message Defined"));
            uxMessagePlaceHolder.Visible = false;
        }

        // Validation Summary
        container = new ContentContainer();
        if (ValidationSummaryTemplate != null)
        {
            ValidationSummaryTemplate.InstantiateIn(container);
            uxValidationSummaryPlaceHolder.Controls.Add(container);
            uxValidationSummaryPanel.Visible = true;
        }
        else
        {
            uxValidationSummaryPlaceHolder.Controls.Add(new LiteralControl("No Validation Summary Defined"));
            uxValidationSummaryPanel.Visible = false;
        }

        // Validation Denotes
        container = new ContentContainer();
        if (ValidationDenotesTemplate != null)
        {
            ValidationDenotesTemplate.InstantiateIn(container);
            uxValidationDenotePlaceHolder.Controls.Add(container);
            uxValidationDenotePanel.Visible = true;
        }
        else
        {
            uxValidationDenotePlaceHolder.Controls.Add(new LiteralControl("No Validation Denotes Defined"));
            uxValidationDenotePanel.Visible = false;
        }

        // If all message disapear message panel will not show.
        if (!uxMessagePlaceHolder.Visible & !uxValidationSummaryPanel.Visible & !uxValidationDenotePanel.Visible)
        {
            uxMessagePanel.Visible = false;
        }
        else
        {
            uxMessagePanel.Visible = true;
        }

        container = new ContentContainer();
        if (LanguageControlTemplate != null)
        {
            LanguageControlTemplate.InstantiateIn(container);
            uxLanguageControlPlaceHolder.Controls.Add(container);
            uxLanguageControlPanel.Visible = true;
        }
        else
        {
            uxLanguageControlPlaceHolder.Controls.Add(new LiteralControl("No Language Control Defined"));
            uxLanguageControlPanel.Visible = false;
        }

        // If don't have any language and message top panel will not show.
        if (!uxMessagePanel.Visible & !uxLanguageControlPanel.Visible)
        {
            uxTopPagePanel.Visible = false;
        }
        else
        {
            uxTopPagePanel.Visible = true;
        }


        if (ButtonEventTemplate == null)
        {
            uxButtonEventPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            ButtonEventTemplate.InstantiateIn(container);
            uxButtonEventPlaceHolder.Controls.Add(container);
            uxButtonEventPanel.Visible = true;
        }

        if (ButtonCommandTemplate == null)
        {
            uxButtonCommandPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            ButtonCommandTemplate.InstantiateIn(container);
            uxButtonCommandPlaceHolder.Controls.Add(container);
            uxButtonCommandPanel.Visible = true;
        }

        container = new ContentContainer();
        if (TopContentBoxTemplate != null)
        {
            TopContentBoxTemplate.InstantiateIn(container);
            uxTopContentBoxPlaceHolder.Controls.Add(container);
            uxTopContentBoxPlaceHolder.Visible = true;
        }
        else
        {
            uxTopContentBoxPlaceHolder.Controls.Add(new LiteralControl("No TopContentBox Content Defined"));
            uxTopContentBoxPlaceHolder.Visible = false;
            uxTopContentBoxPanel.Visible       = false;
        }

        container = new ContentContainer();
        if (ContentTemplate != null)
        {
            ContentTemplate.InstantiateIn(container);
            uxContentPlaceHolder.Controls.Add(container);
            uxContentPanel.Visible = true;
        }
        else
        {
            uxContentPlaceHolder.Controls.Add(new LiteralControl("No Template Defined"));
            uxContentPanel.Visible = false;
        }

        if (FilterTemplate == null)
        {
            uxFilterPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            FilterTemplate.InstantiateIn(container);
            uxFilterPlaceHolder.Controls.Add(container);
            uxFilterPanel.Visible = true;
        }

        if (PageNumberTemplate == null)
        {
            uxPageNumberPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            PageNumberTemplate.InstantiateIn(container);
            uxPageNumberPlaceHolder.Controls.Add(container);
            uxPageNumberPanel.Visible = true;
        }

        if (GridTemplate == null)
        {
            uxGridPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            GridTemplate.InstantiateIn(container);
            uxGridPlaceHolder.Controls.Add(container);
            uxGridPanel.Visible = true;
        }

        if (uxGridPanel.Visible || uxPageNumberPanel.Visible || uxFilterPanel.Visible || uxTopContentBoxPlaceHolder.Visible)
        {
            uxTopContentBoxSet.Visible = true;
        }
        else
        {
            uxTopContentBoxSet.Visible = false;
        }

        if (BottomContentBoxTemplate == null)
        {
            uxBottomContentBoxPlaceHolder.Visible = false;
            uxBottomContentBoxPanel.Visible       = false;
        }
        else
        {
            container = new ContentContainer();
            BottomContentBoxTemplate.InstantiateIn(container);
            uxBottomContentBoxPlaceHolder.Controls.Add(container);
            uxBottomContentBoxPlaceHolder.Visible = true;
        }

        if (FooterTemplate != null)
        {
            container = new ContentContainer();
            FooterTemplate.InstantiateIn(container);
            uxFooterPlaceHolder.Controls.Add(container);
        }

        uxBackToTopHyperLink.Visible = BackToTopLink;
    }