Esempio n. 1
0
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;

            String[] errorMessages = null;
            bool     inError       = false;
            bool     enteredStyle  = false;

            if (!Control.Enabled || !Control.Visible || !Control.ShowSummary)
            {
                return;
            }

            errorMessages = Control.GetErrorMessages(out inError);
            if (!inError)
            {
                return;
            }

            if (Control.DisplayMode == ValidationSummaryDisplayMode.SingleParagraph)
            {
                singleParagraph = true;
            }

            if (Control.HeaderText.Length > 0)
            {
                writer.EnterStyle(Control.ControlStyle);
                enteredStyle = true;
                writer.WriteEncodedText(Control.HeaderText);
                WriteSeparator(writer);
            }

            if (!String.IsNullOrEmpty(errorMessages))
            {
                if (!enteredStyle)
                {
                    writer.EnterStyle(Control.ControlStyle);
                    enteredStyle = true;
                }

                if (singleParagraph)
                {
                    foreach (String errorMessage in errorMessages)
                    {
                        Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
                        writer.WriteEncodedText(errorMessage);
                        WriteSeparator(writer);
                    }
                    writer.WriteBreak();
                }
                else
                {
                    ArrayList arr = new ArrayList();
                    foreach (String errorMessage in errorMessages)
                    {
                        Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
                        arr.Add(errorMessage);
                    }

                    bulletedList.DisplayMode = BulletedListDisplayMode.Text;
                    bulletedList.DataSource  = arr;
                    bulletedList.DataBind();

                    RenderChildren(writer);
                }
            }

            if (enteredStyle)
            {
                writer.ExitStyle(Control.ControlStyle);
            }
        }