public FormElementUserInput(FormElementControl parent, FormElementData data, string answerText, params FormElementDataAnswer[] ansItems) { this._parent = parent; this._qData = data; this._ansText = answerText; this._answers = new FormElementUserInputAnswerCollection(ansItems); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; ListBox lst = new ListBox(); pnl.Controls.Add(lst); lst.ID = "lstElement_" + this._qData.ElementProviderKey.ToString(); lst.ValidationGroup = "DynamicForm_" + this._qData.FormProviderKey.ToString(); if (this._qData.ElementWidth != Unit.Empty) { lst.Width = this._qData.ElementWidth; } if (this._qData.ElementHeight != Unit.Empty) { lst.Height = this._qData.ElementHeight; } foreach (FormElementDataAnswer item in this._qData.Answers.OrderBy(a => a.OrdinalPosition)) { lst.Items.Add(new ListItem(item.AnswerText, item.AnswerProviderKey.ToString())); } this.AnswerControl = lst; base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; Image img = new Image(); pnl.Controls.Add(img); img.ID = "imgElement_" + this._qData.ElementProviderKey.ToString(); img.ImageUrl = this._qData.ImageUrl; if (this._qData.ImageAlignment != ImageAlign.NotSet) { img.ImageAlign = this._qData.ImageAlignment; } if (this._qData.ElementWidth != Unit.Empty) { img.Width = this._qData.ElementWidth; } if (this._qData.ElementHeight != Unit.Empty) { img.Height = this._qData.ElementHeight; } img.AlternateText = this._qData.HintText; base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; base.CreateChildControls(); }
protected override void CreateChildControls() { foreach (FormElementData item in this._qData.Children.OrderBy(c => c.OrdinalPosition)) { this.Controls.Add(FormElementControl.GetControl(item)); } base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; RadioButtonList rdo = new RadioButtonList(); pnl.Controls.Add(rdo); rdo.ID = "rdoLstElement_" + this._qData.ElementProviderKey.ToString(); if (this._qData.ElementWidth != Unit.Empty) { rdo.Width = this._qData.ElementWidth; } if (this._qData.HasHorizontalOption) { rdo.RepeatDirection = RepeatDirection.Horizontal; } else { rdo.RepeatDirection = RepeatDirection.Vertical; } if (this._qData.HasHorizontalOption && this._qData.HasVerticalOption) { throw new Exception("You cannot specify both the horizontal and vertical display options for an element. ProviderKey: " + this._qData.ElementProviderKey.ToString()); } else if (this._qData.HasHorizontalOption) { if (this._qData.ColumnCount > 0) { rdo.RepeatLayout = RepeatLayout.Table; rdo.RepeatColumns = this._qData.ColumnCount; } else { rdo.RepeatLayout = RepeatLayout.Flow; } } else { rdo.RepeatLayout = RepeatLayout.Table; } foreach (FormElementDataAnswer item in this._qData.Answers.OrderBy(a => a.OrdinalPosition)) { rdo.Items.Add(new ListItem(item.AnswerText, item.AnswerProviderKey.ToString())); } this.AnswerControl = rdo; base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void Render(HtmlTextWriter writer) { this.EnsureChildControls(); writer.BeginRender(); try { FormElementControl.AddElementStyleAttributes(writer, this._qData); writer.RenderBeginTag(HtmlTextWriterTag.Table); for (int y = 0; y < this.RowCount; y++) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); for (int x = 0; x < this.ColumnCount; x++) { FormElementData[] cellData = this._qData.Children.Where(c => c.RowIndex == y && c.ColumnIndex == x).ToArray(); if (cellData.Length > 1) { // If we found more than one, I don't even want to try and // figure out how to handle that one right now. throw new Exception(string.Format("Row {0}, Column {1} of the grid contains more than one child cell definition. Cannot render more than one cell in each row/column intersect position.", y + 1, x + 1)); } else if (cellData.Length < 1) { // If no child cell is found at this intersection, just render // an empty table cell, so we don't "break" the HTML output. writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } else if (cellData[0].DisplayType != FormElementDisplayType.GridCell) { // If the item we found isn't for a grid cell, that's a problem. // I'm not coding around that "weirdness". At least not yet. throw new Exception(string.Format("Cannot render a form element of type {0} directly below a Grid element without a parent GridCell. Please check your data for correct parent/child hierarchy.", cellData[0].DisplayType)); } else { // We've got data for a single cell, so create a control. FormElementControl ctrl = FormElementControl.GetControl(cellData[0]); this.Controls.Add(ctrl); ctrl.RenderControl(writer); } } writer.RenderEndTag(); // TR } writer.RenderEndTag(); // TABLE } finally { writer.EndRender(); } base.Render(writer); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; TextBox txt = new TextBox(); pnl.Controls.Add(txt); txt.ID = "txtElement_" + this._qData.ElementProviderKey.ToString(); if (this._qData.ElementWidth != Unit.Empty) { txt.Width = this._qData.ElementWidth; } if (this._qData.ElementHeight != Unit.Empty) { txt.Height = this._qData.ElementHeight; } if (this._qData.BackColor != System.Drawing.Color.Empty) { txt.BackColor = this._qData.BackColor; } if (this._qData.ForeColor != System.Drawing.Color.Empty) { txt.ForeColor = this._qData.ForeColor; } if (this._qData.BorderColor != System.Drawing.Color.Empty) { txt.BorderColor = this._qData.BorderColor; } if (this._qData.BorderStyle != BorderStyle.NotSet) { txt.BorderStyle = this._qData.BorderStyle; } if (this._qData.BorderWidth != Unit.Empty) { txt.BorderWidth = this._qData.BorderWidth; } this.AnswerControl = txt; this.ValidationControl = txt; txt.TextChanged += new EventHandler(this.TextChanged); if (!string.IsNullOrEmpty(this._qData.Suffix)) { pnl.Controls.Add(new LiteralControl(string.Format("<span class=\"formElementSuffix\">{0}</span>", this._qData.Suffix))); } base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { string idVal = this._qData.ElementProviderKey.ToString(); Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; this._hdnFld = new HiddenField(); pnl.Controls.Add(this._hdnFld); this._hdnFld.ID = "hdnElementValue_" + idVal; this._hdnFld.Value = (this._qData.Answers.Count > 0 ? this._qData.Answers[0].AnswerProviderKey.ToString() : string.Empty); this.AnswerControl = this._hdnFld; base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; HyperLink lnk = new HyperLink(); pnl.Controls.Add(lnk); lnk.ID = "lnkElement_" + this._qData.ElementProviderKey.ToString(); lnk.Text = this._qData.Text; lnk.Target = "_blank"; lnk.NavigateUrl = this._qData.NavigationUrl; base.CreateChildControls(); }
//*************************************************************************** // Private Methods // protected override void CreateChildControls() { Panel pnl = FormElementControl.CreateControlContainer(this._qData, this.EditMode); this.Controls.Add(pnl); this.ControlContainer = pnl; DropDownList drp = new DropDownList(); pnl.Controls.Add(drp); drp.AutoPostBack = true; drp.ID = "drpElement_" + this._qData.ElementProviderKey.ToString(); if (this._qData.ElementWidth != Unit.Empty) { drp.Width = this._qData.ElementWidth; } if (this._qData.ElementHeight != Unit.Empty) { drp.Height = this._qData.ElementHeight; } if (this._qData.BackColor != System.Drawing.Color.Empty) { drp.BackColor = this._qData.BackColor; } if (this._qData.ForeColor != System.Drawing.Color.Empty) { drp.ForeColor = this._qData.ForeColor; } drp.Items.Add(new ListItem("- Select -", "")); foreach (FormElementDataAnswer item in this._qData.Answers.OrderBy(a => a.OrdinalPosition)) { drp.Items.Add(new ListItem(item.AnswerText, item.AnswerProviderKey.ToString())); } this.AnswerControl = drp; base.CreateChildControls(); }
//*************************************************************************** // Class Constructors // public DynamicFormElementRenderingEventArgs(FormElementControl element, FormElementData data) : base(element, data) { }
//*************************************************************************** // Class Constructors // public FormElementUserInput(FormElementControl parent, FormElementData data, string answerText) : this(parent, data, answerText, null) { }
protected void SetAsControlParent(FormElementControl ctrl) { ctrl.Owner = this; }
//*************************************************************************** // Class Constructors // public DynamicFormElementEventArgs(FormElementControl element, FormElementData data) { this.FormElement = element; this.FormElementData = data; }