コード例 #1
0
        protected void RenderUplevelItemButton(HtmlTextWriter writer, MultiViewItem item)
        {
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderBeginTag("tr");
            }

            Boolean itemIsCurrent = (item.Title == this.ActiveItem);

            if (!itemIsCurrent)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, this.Owner.Page.ClientScript.GetPostBackEventReference(this.Owner, item.Title));
                writer.AddStyleAttribute("cursor", "pointer");
            }

            MultiViewItemButtonStyle itemStyle = new MultiViewItemButtonStyle();

            if (itemIsCurrent)
            {
                itemStyle.CopyFrom(this.Owner.CurrentButtonStyle);
            }
            itemStyle.MergeWith(this.Owner.ButtonStyle);
            itemStyle.AddAttributesToRender(writer);
            writer.AddStyleAttribute("padding", "5px");
            writer.RenderBeginTag("td");

            if (item.ImageUrl.Length != 0)
            {
                Image itemImageButton = new Image();
                if (!itemIsCurrent)
                {
                    itemImageButton.Attributes["onclick"] = this.Owner.Page.ClientScript.GetPostBackEventReference(this.Owner, item.Title);
                }
                itemImageButton.ImageUrl      = item.ImageUrl;
                itemImageButton.ImageAlign    = ImageAlign.Middle;
                itemImageButton.BorderWidth   = Unit.Pixel(0);
                itemImageButton.ToolTip       = item.Title;
                itemImageButton.AlternateText = item.Title;
                itemImageButton.RenderControl(writer);
                writer.Write(" ");
            }

            HyperLink buttonControl = new HyperLink();

            if (!itemIsCurrent && this.Owner.Page != null)
            {
                buttonControl.NavigateUrl = this.Owner.Page.ClientScript.GetPostBackClientHyperlink(this.Owner, item.Title);
            }
            else
            {
                buttonControl.NavigateUrl = "";
            }
            buttonControl.BorderWidth = Unit.Pixel(0);
            buttonControl.ForeColor   = itemStyle.ForeColor;
            buttonControl.Text        = item.Title;
            buttonControl.RenderControl(writer);

            writer.RenderEndTag();
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderEndTag();
            }
        }
コード例 #2
0
        protected void RenderDownLevelItemButton(HtmlTextWriter writer, MultiViewItem item)
        {
            Boolean itemIsCurrent = (item.Title == this.ActiveItem);

            MultiViewItemButtonStyle itemStyle = new MultiViewItemButtonStyle();

            if (itemIsCurrent)
            {
                itemStyle.CopyFrom(this.Owner.CurrentButtonStyle);
            }
            itemStyle.MergeWith(this.Owner.ButtonStyle);

            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderBeginTag("tr");
            }

            itemStyle.AddAttributesToRender(writer);
            writer.AddStyleAttribute("padding", "5px");
            writer.RenderBeginTag("td");


            if (item.ImageUrl.Length != 0)
            {
                Image itemImageButton;
                if (itemIsCurrent)
                {
                    itemImageButton = new Image();
                }
                else
                {
                    itemImageButton    = new ImageButton();
                    itemImageButton.ID = this.Owner.UniqueID + ":" + item.Title + "_Image";
                }

                itemImageButton.ImageUrl      = item.ImageUrl;
                itemImageButton.ImageAlign    = ImageAlign.Middle;
                itemImageButton.BorderWidth   = Unit.Pixel(0);
                itemImageButton.ToolTip       = item.Title;
                itemImageButton.AlternateText = item.Title;
                itemImageButton.RenderControl(writer);
                writer.Write(" ");
            }

            if (itemIsCurrent)
            {
                writer.Write(item.Title);
            }
            else
            {
                Button itemButton = new Button();
                itemButton.ID        = this.Owner.UniqueID + ":" + item.Title;
                itemButton.Text      = item.Title;
                itemButton.ForeColor = itemStyle.ForeColor;
                itemButton.BackColor = itemStyle.BackColor;
                itemButton.RenderControl(writer);
            }

            writer.RenderEndTag();
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderEndTag();
            }
        }