/// <summary> /// Renders a label and <see cref="T:System.Web.UI.WebControls.TextBox"/> control to the specified <see cref="T:System.Web.UI.HtmlTextWriter"/> object. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> that receives the rendered output.</param> protected override void Render(HtmlTextWriter writer) { writer.AddAttribute("class", "control-group"); writer.RenderBeginTag(HtmlTextWriterTag.Div); label.AddCssClass("control-label"); label.RenderControl(writer); if (!string.IsNullOrWhiteSpace(TextCssClass)) { writer.AddAttribute("class", "controls " + TextCssClass); } else { writer.AddAttribute("class", "controls"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); literal.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// Handles the ItemDataBound event of the rptFiles control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param> protected void rptFiles_ItemDataBound(object sender, RepeaterItemEventArgs e) { var asset = e.Item.DataItem as Asset; if (asset == null) { return; } Label nameLabel = (Label)e.Item.FindControl("lbName"); // Constrain the file name length to 100 characters to prevent it from messing with the UI nameLabel.Text = asset.Name.LeftWithEllipsis(100); if (asset.HasError) { var row = ( HtmlControl )e.Item.FindControl("rptFileRow"); row.Attributes.Add("title", "Error loading file. See the Exception Log for details."); row.AddCssClass("asset-has-error"); nameLabel.AddCssClass("asset-has-error"); Label lbLastModified = (Label)e.Item.FindControl("lbLastModified"); lbLastModified.AddCssClass("asset-has-error"); Label lbFileSize = (Label)e.Item.FindControl("lbFileSize"); lbFileSize.AddCssClass("asset-has-error"); } }
/// <summary> /// Gets the filter compare control. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The identifier.</param> /// <param name="required"></param> /// <returns></returns> public override Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required) { var lbl = new Label(); lbl.ID = string.Format("{0}_lIs", id); lbl.AddCssClass("data-view-filter-label"); lbl.Text = "Is"; return(lbl); }
/// <summary> /// Gets the filter compare control. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The identifier.</param> /// <param name="required">if set to <c>true</c> [required].</param> /// <param name="filterMode">The filter mode.</param> /// <returns></returns> public override Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode) { var lbl = new Label(); lbl.ID = string.Format("{0}_lIs", id); lbl.AddCssClass("data-view-filter-label"); lbl.Text = "Is"; // hide the compare control when in SimpleFilter mode lbl.Visible = filterMode != FilterMode.SimpleFilter; return(lbl); }
/// <summary> /// Handles the RowDataBound event of the gRestKeyList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param> protected void gRestKeyList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var rockContext = new RockContext(); var restUser = e.Row.DataItem as Person; var noteService = new NoteService(rockContext); var description = noteService.Queryable().Where(a => a.EntityId == restUser.Id).FirstOrDefault(); Label lblDescription = e.Row.FindControl("lblDescription") as Label; if (description != null) { lblDescription.Text = description.Text; } var userLoginService = new UserLoginService(rockContext); var userLogin = userLoginService.Queryable().Where(a => a.PersonId == restUser.Id).FirstOrDefault(); Label lblKey = e.Row.FindControl("lblKey") as Label; if (userLogin != null) { lblKey.Text = userLogin.ApiKey; } var activeRecordStatusValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid()).Id; Label lblStatus = e.Row.FindControl("lblStatus") as Label; lblStatus.Text = restUser.RecordStatusValue.Value; lblStatus.AddCssClass("label"); if (restUser.RecordStatusValueId == activeRecordStatusValueId) { lblStatus.AddCssClass("label-success"); } else { lblStatus.AddCssClass("label-danger"); } } }
/// <summary> /// Renders a label and <see cref="T:System.Web.UI.WebControls.TextBox"/> control to the specified <see cref="T:System.Web.UI.HtmlTextWriter"/> object. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> that receives the rendered output.</param> protected override void Render(HtmlTextWriter writer) { writer.AddAttribute("class", "control-group"); writer.RenderBeginTag(HtmlTextWriterTag.Div); label.AddCssClass("control-label"); label.RenderControl(writer); if (Items.Count == 0) { writer.RenderBeginTag(HtmlTextWriterTag.Div); lblNoItemsText.RenderControl(writer); writer.RenderEndTag(); } writer.AddAttribute("class", "controls"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute("class", "checkbox"); writer.RenderBeginTag(HtmlTextWriterTag.Label); base.Render(writer); writer.RenderEndTag(); if (Tip.Trim() != string.Empty) { writer.AddAttribute("class", "help-tip"); writer.AddAttribute("href", "#"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(Tip.Trim()); writer.RenderEndTag(); writer.RenderEndTag(); } if (Help.Trim() != string.Empty) { writer.AddAttribute("class", "help-block"); writer.RenderBeginTag(HtmlTextWriterTag.P); writer.Write(Help.Trim()); writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// Renders a label and <see cref="T:System.Web.UI.WebControls.TextBox"/> control to the specified <see cref="T:System.Web.UI.HtmlTextWriter"/> object. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> that receives the rendered output.</param> protected override void Render(HtmlTextWriter writer) { bool isValid = !Required || requiredFieldValidator.IsValid; writer.AddAttribute("class", "control-group" + (isValid ? "" : " error") + (Required ? " required" : "")); writer.RenderBeginTag(HtmlTextWriterTag.Div); label.AddCssClass("control-label"); label.RenderControl(writer); writer.AddAttribute("class", "controls"); writer.RenderBeginTag(HtmlTextWriterTag.Div); base.Render(writer); if (Required) { requiredFieldValidator.Enabled = true; requiredFieldValidator.ErrorMessage = LabelText + " is Required."; requiredFieldValidator.RenderControl(writer); } if (Tip.Trim() != string.Empty) { writer.AddAttribute("class", "help-tip"); writer.AddAttribute("href", "#"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(Tip.Trim()); writer.RenderEndTag(); writer.RenderEndTag(); } if (Help.Trim() != string.Empty) { writer.AddAttribute("class", "alert alert-info"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.Write(Help.Trim()); writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// Gets the filter compare control. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The identifier.</param> /// <param name="required">if set to <c>true</c> [required].</param> /// <returns></returns> public override Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required) { bool allowMultiple = configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean(); if (allowMultiple) { return(base.FilterCompareControl(configurationValues, id, required)); } else { var lbl = new Label(); lbl.ID = string.Format("{0}_lIs", id); lbl.AddCssClass("data-view-filter-label"); lbl.Text = "Is"; return(lbl); } }
/// <summary> /// Builds the config controls. /// </summary> /// <param name="qualifierValues">The qualifier values.</param> private void BuildConfigControls(Dictionary <string, ConfigurationValue> qualifierValues) { var fieldType = Rock.Web.Cache.FieldTypeCache.Read(int.Parse(ddlFieldType.SelectedValue)); if (fieldType != null) { phFieldTypeQualifiers.Controls.Clear(); var configControls = fieldType.Field.ConfigurationControls(); int i = 0; foreach (var configValue in fieldType.Field.ConfigurationValues(null)) { var ctrlGroup = new HtmlGenericControl("div"); phFieldTypeQualifiers.Controls.Add(ctrlGroup); ctrlGroup.AddCssClass("control-group"); var lbl = new Label(); ctrlGroup.Controls.Add(lbl); lbl.AddCssClass("control-label"); lbl.Text = configValue.Value.Name; var ctrls = new HtmlGenericControl("div"); ctrlGroup.Controls.Add(ctrls); ctrls.AddCssClass("controls"); Control control = configControls[i]; ctrls.Controls.Add(control); control.ID = "configControl_" + configValue.Key; i++; } if (qualifierValues != null) { fieldType.Field.SetConfigurationValues(configControls, qualifierValues); } } }
/// <summary> /// Handles the RowDataBound event of the gBatchList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param> protected void gBatchList_RowDataBound(object sender, GridViewRowEventArgs e) { Rock.Model.FinancialBatch batch = e.Row.DataItem as Rock.Model.FinancialBatch; if (batch != null) { var startDate = Convert.ToDateTime(e.Row.DataItem.GetPropertyValue("BatchStartDateTime")).ToShortDateString(); e.Row.Cells[1].Text = startDate; Literal transactionTotal = e.Row.FindControl("TransactionTotal") as Literal; if (transactionTotal != null) { var data = batch.Transactions.Where(d => d.TotalAmount > 0); var totalSum = data.Sum(d => d.TotalAmount); transactionTotal.Text = string.Format("{0:C}", totalSum); Label variance = e.Row.FindControl("lblVariance") as Label; if (variance != null) { if (batch.ControlAmount > 0) { var varianceAmount = Convert.ToDecimal(batch.ControlAmount) - totalSum; variance.Text = string.Format("{0:C}", varianceAmount); if (varianceAmount != 0) { variance.AddCssClass("text-danger"); } } } } Literal transactionCount = e.Row.FindControl("TransactionCount") as Literal; if (transactionCount != null) { transactionCount.Text = batch.Transactions.Count.ToString(); } var status = e.Row.DataItem.GetPropertyValue("Status").ToString(); if (!string.IsNullOrWhiteSpace(status)) { switch (status.ToUpper()) { case "CLOSED": e.Row.Cells[7].Text = "<span class='label label-success'>Closed</span>"; break; case "OPEN": e.Row.Cells[7].Text = "<span class='label label-warning'>Open</span>"; break; case "PENDING": e.Row.Cells[7].Text = "<span class='label label-default'>Pending</span>"; break; } } // Get any warnings for this row and display them in the Warnings column Label warnings = e.Row.FindControl("lblWarnings") as Label; var warningList = GetWarnings(batch); if (warningList != null) { foreach (var warning in warningList) { switch (warning.ToUpper()) { case "UNTIED": warnings.Text += "<span class='label label-danger'>Untied Transactions</span>"; break; } } } } }
/// <summary> /// Generates tables /// </summary> private void GenerateTable() { tblData.Controls.Clear(); Hashtable ht = data.ConvertToHashtable(); TableHeaderRow th = new TableHeaderRow() { TableSection = TableRowSection.TableHeader }; TableHeaderCell ha = new TableHeaderCell(); TableHeaderCell hn = new TableHeaderCell(); TableHeaderCell hv = new TableHeaderCell(); th.CssClass = "unigrid-head"; ha.Text = GetString("unigrid.actions"); ha.CssClass = "unigrid-actions-header"; hn.Text = GetString("xmleditor.propertyname"); hn.Width = Unit.Pixel(180); hv.Text = GetString("xmleditor.propertyvalue"); hv.Width = Unit.Pixel(500); th.Cells.Add(ha); th.Cells.Add(hn); th.Cells.Add(hv); tblData.Rows.Add(th); ArrayList keys = new ArrayList(ht); keys.Sort(new CustomStringComparer()); foreach (DictionaryEntry okey in keys) { String key = ValidationHelper.GetString(okey.Key, String.Empty); String value = ValidationHelper.GetString(okey.Value, String.Empty); bool isInvalid = (key == INVALIDTOKEN); key = isInvalid ? invalidKey : key; if (value == String.Empty) { continue; } TableRow tr = new TableRow(); // Actions TableCell tna = new TableCell(); tna.CssClass = "unigrid-actions"; var imgEdit = new CMSGridActionButton(); imgEdit.OnClientClick = String.Format("displayEdit('{1}','{0}'); return false; ", key, ClientID); imgEdit.IconCssClass = "icon-edit"; imgEdit.IconStyle = GridIconStyle.Allow; imgEdit.ID = key + "_edit"; imgEdit.ToolTip = GetString("xmleditor.edititem"); var imgOK = new CMSGridActionButton(); imgOK.IconCssClass = "icon-check"; imgOK.IconStyle = GridIconStyle.Allow; imgOK.OnClientClick = String.Format("approveCustomChanges('{0}','{1}');return false;", ClientID, key); imgOK.ID = key + "_ok"; imgOK.ToolTip = GetString("xmleditor.approvechanges"); var imgDelete = new CMSGridActionButton(); imgDelete.OnClientClick = " if (confirm('" + GetString("xmleditor.deleteconfirm") + "')) {" + ControlsHelper.GetPostBackEventReference(tblData, "delete_" + key) + "} ;return false;"; imgDelete.IconCssClass = "icon-bin"; imgDelete.IconStyle = GridIconStyle.Critical; imgDelete.ID = key + "_del"; imgDelete.ToolTip = GetString("xmleditor.deleteitem"); var imgUndo = new CMSGridActionButton(); imgUndo.OnClientClick = String.Format("if (confirm('" + GetString("xmleditor.confirmcancel") + "')) undoCustomChanges('{0}','{1}'); return false;", ClientID, key); imgUndo.IconCssClass = "icon-arrow-crooked-left"; imgUndo.ID = key + "_undo"; imgUndo.ToolTip = GetString("xmleditor.undochanges"); tna.Controls.Add(imgEdit); tna.Controls.Add(imgOK); tna.Controls.Add(imgDelete); tna.Controls.Add(imgUndo); value = MacroSecurityProcessor.RemoveSecurityParameters(value, false, null); // Labels Label lblName = new Label(); lblName.ID = "sk" + key; lblName.Text = key; Label lblValue = new Label(); lblValue.ID = "sv" + key; lblValue.Text = value; // Textboxes CMSTextBox txtName = new CMSTextBox(); txtName.Text = key; txtName.ID = "tk" + key; txtName.CssClass = "XmlEditorTextbox"; CMSTextBox txtValue = new CMSTextBox(); txtValue.Text = value; txtValue.ID = "tv" + key; txtValue.CssClass = "XmlEditorTextbox"; txtValue.Width = Unit.Pixel(490); labels.Add(lblName); labels.Add(lblValue); textboxes.Add(txtName); textboxes.Add(txtValue); TableCell tcn = new TableCell(); tcn.Controls.Add(lblName); tcn.Controls.Add(txtName); TableCell tcv = new TableCell(); tcv.Controls.Add(lblValue); tcv.Controls.Add(txtValue); tr.Cells.Add(tna); tr.Cells.Add(tcn); tr.Cells.Add(tcv); tblData.Rows.Add(tr); lblValue.CssClass = String.Empty; lblName.CssClass = "CustomEditorKeyClass"; if (isInvalid) { imgDelete.AddCssClass("hidden"); imgEdit.AddCssClass("hidden"); lblName.AddCssClass("hidden"); lblValue.AddCssClass("hidden"); RegisterEnableScript(false); } else { imgOK.AddCssClass("hidden"); imgUndo.AddCssClass("hidden"); txtName.CssClass += " hidden"; txtValue.CssClass += " hidden"; } } }
/// <summary> /// Generates tables /// </summary> private void GenerateTable() { tblData.Controls.Clear(); Hashtable ht = data.ConvertToHashtable(); TableHeaderRow th = new TableHeaderRow() { TableSection = TableRowSection.TableHeader }; TableHeaderCell ha = new TableHeaderCell(); TableHeaderCell hn = new TableHeaderCell(); TableHeaderCell hv = new TableHeaderCell(); th.CssClass = "unigrid-head"; ha.Text = GetString("unigrid.actions"); ha.CssClass = "unigrid-actions-header"; hn.Text = GetString("xmleditor.propertyname"); hn.Width = Unit.Pixel(180); hv.Text = GetString("xmleditor.propertyvalue"); hv.Width = Unit.Pixel(500); th.Cells.Add(ha); th.Cells.Add(hn); th.Cells.Add(hv); tblData.Rows.Add(th); ArrayList keys = new ArrayList(ht); keys.Sort(new CustomStringComparer()); foreach (DictionaryEntry okey in keys) { String key = ValidationHelper.GetString(okey.Key, String.Empty); String value = ValidationHelper.GetString(okey.Value, String.Empty); bool isInvalid = (key == INVALIDTOKEN); key = isInvalid ? invalidKey : key; if (value == String.Empty) { continue; } TableRow tr = new TableRow(); // Actions TableCell tna = new TableCell(); tna.CssClass = "unigrid-actions"; var imgEdit = new CMSGridActionButton(); imgEdit.OnClientClick = String.Format("displayEdit('{1}','{0}'); return false; ", key, ClientID); imgEdit.IconCssClass = "icon-edit"; imgEdit.IconStyle = GridIconStyle.Allow; imgEdit.ID = key + "_edit"; imgEdit.ToolTip = GetString("xmleditor.edititem"); var imgOK = new CMSGridActionButton(); imgOK.IconCssClass = "icon-check"; imgOK.IconStyle = GridIconStyle.Allow; imgOK.OnClientClick = String.Format("approveCustomChanges('{0}','{1}');return false;", ClientID, key); imgOK.ID = key + "_ok"; imgOK.ToolTip = GetString("xmleditor.approvechanges"); var imgDelete = new CMSGridActionButton(); imgDelete.OnClientClick = " if (confirm('" + GetString("xmleditor.deleteconfirm") + "')) {" + ControlsHelper.GetPostBackEventReference(tblData, "delete_" + key) + "} ;return false;"; imgDelete.IconCssClass = "icon-bin"; imgDelete.IconStyle = GridIconStyle.Critical; imgDelete.ID = key + "_del"; imgDelete.ToolTip = GetString("xmleditor.deleteitem"); var imgUndo = new CMSGridActionButton(); imgUndo.OnClientClick = String.Format("if (confirm('" + GetString("xmleditor.confirmcancel") + "')) undoCustomChanges('{0}','{1}'); return false;", ClientID, key); imgUndo.IconCssClass = "icon-arrow-crooked-left"; imgUndo.ID = key + "_undo"; imgUndo.ToolTip = GetString("xmleditor.undochanges"); tna.Controls.Add(imgEdit); tna.Controls.Add(imgOK); tna.Controls.Add(imgDelete); tna.Controls.Add(imgUndo); value = MacroSecurityProcessor.RemoveSecurityParameters(value, false, null); // Labels Label lblName = new Label(); lblName.ID = "sk" + key; lblName.Text = key; Label lblValue = new Label(); lblValue.ID = "sv" + key; lblValue.Text = value; // Textboxes CMSTextBox txtName = new CMSTextBox(); txtName.Text = key; txtName.ID = "tk" + key; txtName.CssClass = "XmlEditorTextbox"; CMSTextBox txtValue = new CMSTextBox(); txtValue.Text = value; txtValue.ID = "tv" + key; txtValue.CssClass = "XmlEditorTextbox"; txtValue.Width = Unit.Pixel(490); labels.Add(lblName); labels.Add(lblValue); textboxes.Add(txtName); textboxes.Add(txtValue); TableCell tcn = new TableCell(); tcn.Controls.Add(lblName); tcn.Controls.Add(txtName); TableCell tcv = new TableCell(); tcv.Controls.Add(lblValue); tcv.Controls.Add(txtValue); tr.Cells.Add(tna); tr.Cells.Add(tcn); tr.Cells.Add(tcv); tblData.Rows.Add(tr); lblValue.CssClass = String.Empty; lblName.CssClass = "CustomEditorKeyClass"; if (isInvalid) { imgDelete.AddCssClass("hidden"); imgEdit.AddCssClass("hidden"); lblName.AddCssClass("hidden"); lblValue.AddCssClass("hidden"); RegisterEnableScript(false); } else { imgOK.AddCssClass("hidden"); imgUndo.AddCssClass("hidden"); txtName.CssClass += " hidden"; txtValue.CssClass += " hidden"; } } }
/// <summary> /// Adds edit controls for each of the item's attributes /// </summary> /// <param name="item"></param> /// <param name="parentControl"></param> /// <param name="setValue"></param> /// <param name="exclude">List of attribute names not to render</param> public static void AddEditControls(IHasAttributes item, Control parentControl, bool setValue, List <string> exclude) { if (item.Attributes != null) { foreach (var category in item.AttributeCategories) { HtmlGenericControl fieldSet = new HtmlGenericControl("fieldset"); parentControl.Controls.Add(fieldSet); fieldSet.Controls.Clear(); HtmlGenericControl legend = new HtmlGenericControl("legend"); fieldSet.Controls.Add(legend); legend.Controls.Clear(); legend.InnerText = category.Key.Trim() != string.Empty ? category.Key.Trim() : "Attributes"; foreach (string key in category.Value) { var attribute = item.Attributes[key]; if (!exclude.Contains(attribute.Name)) { HtmlGenericControl div = new HtmlGenericControl("div"); fieldSet.Controls.Add(div); div.Controls.Clear(); div.ID = string.Format("attribute_{0}", attribute.Id); div.AddCssClass("control-group"); if (attribute.IsRequired) { div.AddCssClass("required"); } div.Attributes.Add("attribute-key", attribute.Key); div.ClientIDMode = ClientIDMode.AutoID; Label lbl = new Label(); div.Controls.Add(lbl); lbl.ClientIDMode = ClientIDMode.AutoID; lbl.AddCssClass("control-label"); lbl.Text = attribute.Name; lbl.AssociatedControlID = string.Format("attribute_field_{0}", attribute.Id); HtmlGenericControl divControls = new HtmlGenericControl("div"); div.Controls.Add(divControls); divControls.Controls.Clear(); divControls.AddCssClass("controls"); Control attributeControl = attribute.CreateControl(item.AttributeValues[attribute.Key][0].Value, setValue); attributeControl.ID = string.Format("attribute_field_{0}", attribute.Id); attributeControl.ClientIDMode = ClientIDMode.AutoID; divControls.Controls.Add(attributeControl); if (attribute.IsRequired && (attributeControl is TextBox)) { RequiredFieldValidator rfv = new RequiredFieldValidator(); divControls.Controls.Add(rfv); rfv.CssClass = "help-inline"; rfv.ControlToValidate = attributeControl.ID; rfv.ID = string.Format("attribute_rfv_{0}", attribute.Id); rfv.ErrorMessage = string.Format("{0} is Required", attribute.Name); rfv.Display = ValidatorDisplay.None; if (!setValue && !rfv.IsValid) { div.Attributes.Add("class", "error"); } } if (!string.IsNullOrEmpty(attribute.Description)) { HtmlGenericControl helpBlock = new HtmlGenericControl("div"); divControls.Controls.Add(helpBlock); helpBlock.ClientIDMode = ClientIDMode.AutoID; helpBlock.AddCssClass("alert alert-info"); helpBlock.InnerHtml = attribute.Description; } } } } } }