示例#1
0
/* ------------------------------------------------------------------------
 * second to last stage of Page processing; Page object calls method on
 * control to write out control's markup to sent to browser.
 * ------------------------------------------------------------------------
 */
        protected override void Render(HtmlTextWriter w)
        {
            if (_label != null)
            {
                if (required)
                {
                    _label = ControlFactory.REQUIRED_FLAG + _label;
                }
                w.Write(ControlFactory.DIV_LABEL_FORMAT, ClientID, _label);
            }
// for client-side validation
            w.Write("<span>");

/*
 * must add at this stage in the Page life cycle to allow
 * setting 'required' flag on/off!
 *
 * HTML 'class' attribute, for client-side validation;
 */

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * control has extra class attributes compared to OTHER CONTROLS IN PROJECT
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */
            if (required)
            {
                classAttributes += ControlFactory.CHECKBOX_CLASS;
                //classAttributes += " " + ControlFactory.LIST_MULTIPLE_REQUIRED_CLASS
                // + " " + ControlFactory.REQUIRED_ATTR
                //;
                w.AddAttribute(ControlFactory.REQUIRED_ATTR, null);
            }
            if (EnableJavaScriptCheckAll)
            {
                classAttributes += " " + ControlFactory.CHECKBOXLIST_CHECKALL_CLASS;
            }
// server-side error highlighting
            if (Page.IsPostBack && _rfv != null && !_rfv.IsValid)
            {
                classAttributes += " " + ControlFactory.ERROR_CLASS;
                ControlFactory.AddServerRequiredStyle(w);
            }
// HTML class attribute(s)
            if (!string.IsNullOrEmpty(classAttributes))
            {
                w.AddAttribute(HtmlTextWriterAttribute.Class, ClassAttributes);
            }

            base.Render(w);

// server-side validator
            if (required && _rfv != null)
            {
                _rfv.RenderControl(w);
            }
            w.Write("</span>");
        }
示例#2
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Controls.Clear();
/* ignore validation if control **NOT** enabled */
            if (!this.Enabled)
            {
                return;
            }
/* add RequiredFieldValidator */
            if (required)
            {
                _rfv = ControlFactory.GetRequiredValidator(
                    this.ID, this.ValidationGroup
                    );
                Controls.Add(_rfv);
            }
/* add RegularExpressionValidator */
            if (!String.IsNullOrEmpty(regex))
            {
                addRegexValidator();
            }

/*
 * client-side JavaScript character counter; **MUST** edit plugin file
 * to call on all server control(s)
 */
            if (TextMode == TextBoxMode.MultiLine && MaxLength > 0)
            {
                Attributes.Add(ControlFactory.MAXLENGTH_ATTR, MaxLength.ToString());
                Type cstype            = this.GetType();
                ClientScriptManager cs = Page.ClientScript;
// verify web.config <appSettings> keys exist
                if (!string.IsNullOrEmpty(_jsPath))
                {
                    if (!cs.IsClientScriptBlockRegistered(cstype, _jsPath))
                    {
                        Literal l = new Literal()
                        {
                            Text = String.Format(StringFormat.TAG_SCRIPT, _jsPath)
                        };
                        Page.Header.Controls.Add(l);
                        cs.RegisterClientScriptBlock(cstype, _jsPath, "");
                    }
                }
            }

/* add CompareValidator */
            AddCompareValidator();
/* client-side validation => ValidationGroup */
            if (ValidationGroup != String.Empty)
            {
                Attributes.Add(ControlFactory.VALIDATION_GROUP_ATTR, ValidationGroup);
            }
        }
示例#3
0
/* ------------------------------------------------------------------------
 * second to last stage of Page processing; Page object calls method on
 * control to write out control's markup to sent to browser.
 * ------------------------------------------------------------------------
 */
        protected override void Render(HtmlTextWriter w)
        {
            if (_label != null)
            {
                if (required)
                {
                    _label = ControlFactory.REQUIRED_FLAG + _label;
                }
                w.Write(ControlFactory.DIV_LABEL_FORMAT, ClientID, _label);
            }
// for client-side validation
            w.Write("<span>");

/*
 * must add at this stage in the Page life cycle to allow
 * setting 'required' flag on/off!
 *
 * HTML 'class' attribute, for client-side validation;
 */
            if (required)
            {
                classAttributes += " " + ControlFactory.RADIOBUTTONLIST_CLASS;

/*
 + " "
 +  ControlFactory.REQUIRED_ATTR;
 */
                w.AddAttribute(ControlFactory.REQUIRED_ATTR, null);
            }
// server-side error highlighting
            if (Page.IsPostBack && _rfv != null && !_rfv.IsValid)
            {
                classAttributes += " " + ControlFactory.ERROR_CLASS;
                ControlFactory.AddServerRequiredStyle(w);
            }
// HTML class attribute(s)
            if (!string.IsNullOrEmpty(classAttributes))
            {
                w.AddAttribute(HtmlTextWriterAttribute.Class, ClassAttributes);
            }

            base.Render(w);
// server-side validator
            if (required && _rfv != null)
            {
                _rfv.RenderControl(w);
            }
            w.Write("</span>");
        }
示例#4
0
// ----------------------------------------------------------------------------
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
// ignore validation if control is **NOT** enabled
            if (!this.Enabled)
            {
                return;
            }

            if (required)
            {
                _rfv = ControlFactory.GetRequiredValidator(
                    this.ID, this.ValidationGroup
                    );
                Controls.Add(_rfv);
            }
// client-side validation => ValidationGroup
            if (ValidationGroup != String.Empty)
            {
                Attributes.Add(ControlFactory.VALIDATION_GROUP_ATTR, ValidationGroup);
            }
        }
示例#5
0
/* ------------------------------------------------------------------------
 * second to last stage of Page processing; Page object calls method on
 * control to write out control's markup to sent to browser.
 * ------------------------------------------------------------------------
 */
        protected override void Render(HtmlTextWriter w)
        {
// block label takes precendence
            if (_label != null)
            {
                if (required)
                {
                    _label = ControlFactory.REQUIRED_FLAG + _label;
                }
                w.Write(ControlFactory.DIV_LABEL_FORMAT, ClientID, _label);
            }
            else if (_inlineLabel != null)
            {
                if (required)
                {
                    _inlineLabel = ControlFactory.REQUIRED_FLAG + _inlineLabel;
                }
                w.Write(ControlFactory.SPAN_LABEL_FORMAT, ClientID, _inlineLabel);
            }

/*
 *    if (!string.IsNullOrEmpty(PlaceholderAttr)) {
 *      w.AddAttribute(ControlFactory.REQUIRED_ATTR, PlaceholderAttr);
 *    }
 */

            classAttributes += " " + ControlFactory.BOOTSTRAP_FORM_CLASS;

/* ------------------------------------------------------------------------
 * must add at this stage in the Page life cycle to allow
 * setting 'required' flag on/off!
 *
 * HTML 'class' attribute, for client-side validation;
 * ------------------------------------------------------------------------
 */
            if (required)
            {
                w.AddAttribute(ControlFactory.REQUIRED_ATTR, null);
            }
// server-side error highlighting
            if (Page.IsPostBack)
            {
                if (_rfv != null && !_rfv.IsValid ||
                    _rev != null && !_rev.IsValid ||
                    _cv != null && !_cv.IsValid
                    )
                {
                    classAttributes += " " + ControlFactory.ERROR_CLASS;
                    ControlFactory.AddServerRequiredStyle(w);
                }
            }
// HTML class attribute(s)
            if (!string.IsNullOrEmpty(classAttributes))
            {
                w.AddAttribute(HtmlTextWriterAttribute.Class, ClassAttributes);
            }

            base.Render(w);
// server-side validator
            foreach (Control c in Controls)
            {
                if (c is BaseValidator)
                {
                    c.RenderControl(w);
                }
            }
        }