示例#1
0
        /// <summary>
        /// Renders the container
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            if (Text == "" && !DesignMode)
            {
                base.Render(writer);
                return;
            }

            if (RenderMode == RenderModes.Text)
            {
                Text = StringUtils.DisplayMemo(Text);
            }

            string TStyle     = Style["position"];
            bool   IsAbsolute = false;

            if (TStyle != null && TStyle.Trim() == "absolute")
            {
                IsAbsolute = true;
            }

            // <Center> is still the only reliable way to get block structures centered
            if (!IsAbsolute && Center)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.MarginLeft, "auto");
                writer.AddStyleAttribute(HtmlTextWriterStyle.MarginRight, "auto");

                // In designmode we want to write out a container so it
                // so the designer properly shows the controls as block control
                if (DesignMode)
                {
                    writer.Write("<div style='width:100%'>");
                }
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Width.ToString());

            foreach (string Key in Style.Keys)
            {
                writer.AddStyleAttribute(Key, Style[Key]);
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Div);


            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Set up  image <td> tag
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            if (ErrorImage != "")
            {
                string ImageUrl = ErrorImage.ToLower();
                if (ImageUrl == "warningresource")
                {
                    ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), ControlResources.WARNING_ICON_RESOURCE);
                }
                else if (ImageUrl == "inforesource")
                {
                    ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), ControlResources.INFO_ICON_RESOURCE);
                }
                else
                {
                    ImageUrl = ResolveUrl(ErrorImage);
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Src, ImageUrl);
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }

            writer.RenderEndTag();  // image <td>

            // Render content <td> tag
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            if (UserMessage != "")
            {
                writer.Write("<span style='font-weight:normal'>" + UserMessage + "</span><hr />");
            }

            writer.Write(Text);

            writer.RenderEndTag();  // Content <td>
            writer.RenderEndTag();  // </tr>
            writer.RenderEndTag();  // </table>

            writer.RenderEndTag();  // </div>

            if (!IsAbsolute)
            {
                if (Center)
                {
                    if (DesignMode)
                    {
                        writer.Write("</div>");  // </div>
                    }
                }

                writer.WriteBreak();
            }
        }
示例#2
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (Text == "" && !DesignMode)
            {
                base.Render(writer);
                return;
            }

            if (RenderMode == RenderModes.Text)
            {
                Text = Text.Replace("\r\n", "</br>");
            }

            //if (this.Center)
            //    writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "center");
            //writer.RenderBeginTag(HtmlTextWriterTag.Div);

            // *** <Center> is still the only reliable way to get block structures centered
            if (Center)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Center);
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, CellPadding);
            writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "30px");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Width.ToString());
            writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "left");

            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // *** Set up  image <td> tag
            writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "16px");

            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            if (ErrorImage != "")
            {
                string ImageUrl = ErrorImage.ToLower();
                if (ImageUrl == "warningresource")
                {
                    ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), ControlsResources.WARNING_ICON_RESOURCE);
                }
                else if (ImageUrl == "inforesource")
                {
                    ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), ControlsResources.INFO_ICON_RESOURCE);
                }
                else
                {
                    ImageUrl = ResolveUrl(ErrorImage);
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Src, ImageUrl);
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }

            writer.RenderEndTag(); // image <td>

            // *** Render content <td> tag
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            if (UserMessage != "")
            {
                writer.Write("<span style='font-weight:normal'>" + UserMessage + "</span><hr />");
            }

            writer.Write(Text);

            writer.RenderEndTag(); // Content <td>
            writer.RenderEndTag(); // <tr>
            writer.RenderEndTag(); // <table>

            if (Center)
            {
                writer.RenderEndTag(); // </center>
            }
            writer.WriteBreak();

            //writer.RenderEndTag();  // </div>
        }