Ejemplo n.º 1
0
        /// <summary>
        /// Writes the AddressLine content to the specified HtmlTextWriter object, for display on the client.
        /// </summary>
        /// <param name="addressLine">The AddressLine to Render</param>
        /// <param name="name">The name of the AddressLine, e.g. AddressLine1 or Postcode</param>
        /// <param name="cssClass">A CSS to attach to the address line's input element.</param>
        /// <param name="writer">An HtmlTextWriter that represents the output stream to render HTML content on the client.</param>
        private void RenderAddressLine(AddressLine addressLine, string name, string cssClass, HtmlTextWriter writer)
        {
            if (addressLine.Visible)
            {
                writer.RenderBeginTag("tr");
                writer.WriteLine();
                writer.Indent++;

                // Render the label cell
                writer.RenderBeginTag("td");
                if (addressLine.ShowLabel == true)
                {
                    // ShowLabel is true so render the label control into the label cell
                    this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_Label", name)).RenderControl(writer);
                }

                writer.RenderEndTag();

                if (cssClass != null)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
                }

                writer.RenderBeginTag("td");

                this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name)).RenderControl(writer);

                writer.RenderEndTag();

                // render the validation

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "errorCell");
                writer.RenderBeginTag("td");

                if (addressLine.Mandatory == true)
                {
                    // Input for this address line is mandatory so render out the RequiredFieldValidator
                    this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_RequiredFieldVal", name)).RenderControl(writer);
                }

                if (addressLine.ValidationExpression != null)
                {
                    this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_RegularExpressionVal", name)).RenderControl(writer);
                }

                writer.RenderEndTag();
                writer.Indent--;

                writer.Indent--;
                writer.RenderEndTag();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called from CreateChildControls to create the necessary child controls for an AddressLine
        /// </summary>
        /// <param name="addressLine">The AddressLine to create the controls for</param>
        /// <param name="name">Name of the AddressLine, e.g. addressLine1 or postcode</param>
        private void CreateAddressLineChildControls(AddressLine addressLine, string name)
        {
            if (addressLine.Visible == true)
            {
                if (addressLine.ShowLabel == true)
                {
                    // A label is requested for this address line is mandatory so create a Label
                    Label lbl = new Label();
                    lbl.ID = string.Format(CultureInfo.InvariantCulture, "{0}_Label", name);
                    lbl.AssociatedControlID = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);
                    lbl.Text = addressLine.LabelText;

                    this.Controls.Add(lbl);
                }

                if (addressLine.Mandatory == true)
                {
                    // Input for this address line is mandatory so create a RequiredFieldValidator
                    RequiredFieldValidator rfv = new RequiredFieldValidator();
                    rfv.ID = string.Format(CultureInfo.InvariantCulture, "{0}_RequiredFieldVal", name);
                    rfv.ControlToValidate = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);
                    rfv.Display           = ValidatorDisplay.Dynamic;
                    rfv.ErrorMessage      = "* required field";

                    this.Controls.Add(rfv);
                }

                if (addressLine.ValidationExpression != null)
                {
                    // A validation expression has been specified for this AddressLine so create a RegularExpressionValidator
                    RegularExpressionValidator regfv = new RegularExpressionValidator();
                    regfv.ID = string.Format(CultureInfo.InvariantCulture, "{0}_RegularExpressionVal", name);
                    regfv.ControlToValidate    = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);
                    regfv.Display              = ValidatorDisplay.Dynamic;
                    regfv.ValidationExpression = addressLine.ValidationExpression;
                    regfv.ErrorMessage         = "* invalid data";

                    this.Controls.Add(regfv);
                }

                TextBox tb = new TextBox();
                tb.ID = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);

                this.Controls.Add(tb);

                // Pass the textbox down to the address line so it can refer to it internally
                addressLine.PassInputControl(tb);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes the AddressLine content to the specified HtmlTextWriter object, for display on the client.
        /// </summary>
        /// <param name="addressLine">The AddressLine to Render</param>
        /// <param name="name">The name of the AddressLine, e.g. AddressLine1 or Postcode</param>
        /// <param name="cssClass">A CSS to attach to the address line's input element.</param>
        /// <param name="writer">An HtmlTextWriter that represents the output stream to render HTML content on the client.</param>
        private void RenderAddressLine(AddressLine addressLine, string name, string cssClass, HtmlTextWriter writer)
        {
            if (addressLine.Visible)
            {
                writer.RenderBeginTag("tr");
                writer.WriteLine();
                writer.Indent++;

                // Render the label cell
                writer.RenderBeginTag("td");
                if (addressLine.ShowLabel == true)
                {
                    // ShowLabel is true so render the label control into the label cell
                    this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_Label", name)).RenderControl(writer);
                }

                writer.RenderEndTag();

                if (cssClass != null)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
                }

                writer.RenderBeginTag("td");

                this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name)).RenderControl(writer);

                writer.RenderEndTag();

                // render the validation

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "errorCell");
                writer.RenderBeginTag("td");

                if (addressLine.Mandatory == true)
                {
                    // Input for this address line is mandatory so render out the RequiredFieldValidator
                    this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_RequiredFieldVal", name)).RenderControl(writer);
                }

                if (addressLine.ValidationExpression != null)
                {
                    this.FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_RegularExpressionVal", name)).RenderControl(writer);
                }

                writer.RenderEndTag();
                writer.Indent--;

                writer.Indent--;
                writer.RenderEndTag();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called from CreateChildControls to create the necessary child controls for an AddressLine
        /// </summary>
        /// <param name="addressLine">The AddressLine to create the controls for</param>
        /// <param name="name">Name of the AddressLine, e.g. addressLine1 or postcode</param>
        private void CreateAddressLineChildControls(AddressLine addressLine, string name)
        {
            if (addressLine.Visible == true)
            {
                if (addressLine.ShowLabel == true)
                {
                    // A label is requested for this address line is mandatory so create a Label
                    Label lbl = new Label();
                    lbl.ID = string.Format(CultureInfo.InvariantCulture, "{0}_Label", name);
                    lbl.AssociatedControlID = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);
                    lbl.Text = addressLine.LabelText;

                    this.Controls.Add(lbl);
                }

                if (addressLine.Mandatory == true)
                {
                    // Input for this address line is mandatory so create a RequiredFieldValidator
                    RequiredFieldValidator rfv = new RequiredFieldValidator();
                    rfv.ID = string.Format(CultureInfo.InvariantCulture, "{0}_RequiredFieldVal", name);
                    rfv.ControlToValidate = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);
                    rfv.Display = ValidatorDisplay.Dynamic;
                    rfv.ErrorMessage = "* required field";

                    this.Controls.Add(rfv);
                }

                if (addressLine.ValidationExpression != null)
                {
                    // A validation expression has been specified for this AddressLine so create a RegularExpressionValidator
                    RegularExpressionValidator regfv = new RegularExpressionValidator();
                    regfv.ID = string.Format(CultureInfo.InvariantCulture, "{0}_RegularExpressionVal", name);
                    regfv.ControlToValidate = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);
                    regfv.Display = ValidatorDisplay.Dynamic;
                    regfv.ValidationExpression = addressLine.ValidationExpression;
                    regfv.ErrorMessage = "* invalid data";

                    this.Controls.Add(regfv);
                }

                TextBox tb = new TextBox();
                tb.ID = string.Format(CultureInfo.InvariantCulture, "{0}_TextBox", name);

                this.Controls.Add(tb);

                // Pass the textbox down to the address line so it can refer to it internally
                addressLine.PassInputControl(tb);
            }
        }