/// <summary> /// Enables and sets the appropriate CSS class on the install buttons and each div panel. /// </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 rptPackageVersions_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { IPackage package = e.Item.DataItem as IPackage; if (package != null) { Boolean isExactPackageInstalled = NuGetService.IsPackageInstalled(package); LinkButton lbInstall = e.Item.FindControl("lbInstall") as LinkButton; var divPanel = e.Item.FindControl("divPanel") as HtmlGenericControl; // Only the last item in the list is the primary if (e.Item.ItemIndex == _numberOfAvailablePackages - 1) { lbInstall.Enabled = true; lbInstall.AddCssClass("btn-info"); divPanel.AddCssClass("panel-info"); } else { lbInstall.Enabled = false; lbInstall.Text = "Pending"; lbInstall.AddCssClass("btn-default"); divPanel.AddCssClass("panel-block"); } } } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _noteNew = new NoteControl(); _noteNew.ID = "noteNew"; _noteNew.SaveButtonClick += note_SaveButtonClick; Controls.Add(_noteNew); _lbShowMore = new LinkButton(); _lbShowMore.ID = "lbShowMore"; _lbShowMore.Click += _lbShowMore_Click; _lbShowMore.AddCssClass("load-more btn btn-xs btn-action"); Controls.Add(_lbShowMore); var iDownPre = new HtmlGenericControl("i"); iDownPre.Attributes.Add("class", "fa fa-angle-down"); _lbShowMore.Controls.Add(iDownPre); var spanDown = new HtmlGenericControl("span"); spanDown.InnerHtml = " Load More "; _lbShowMore.Controls.Add(spanDown); var iDownPost = new HtmlGenericControl("i"); iDownPost.Attributes.Add("class", "fa fa-angle-down"); _lbShowMore.Controls.Add(iDownPost); }
/// <summary> /// When implemented by a class, defines the <see cref="T:System.Web.UI.Control"/> object that child controls and templates belong to. These child controls are in turn defined within an inline template. /// </summary> /// <param name="container">The <see cref="T:System.Web.UI.Control"/> object to contain the instances of controls from the inline template.</param> public void InstantiateIn(Control container) { DataControlFieldCell cell = container as DataControlFieldCell; if (cell != null) { DeleteField deleteField = cell.ContainingField as DeleteField; ParentGrid = deleteField.ParentGrid; LinkButton lbDelete = new LinkButton(); lbDelete.CausesValidation = false; lbDelete.CssClass = "btn btn-danger btn-sm grid-delete-button"; if (lbDelete.Enabled && (!ParentGrid.Enabled || !ParentGrid.IsDeleteEnabled)) { lbDelete.AddCssClass("disabled"); lbDelete.Enabled = false; } lbDelete.ToolTip = "Delete"; HtmlGenericControl buttonIcon = new HtmlGenericControl("i"); buttonIcon.Attributes.Add("class", "fa fa-times"); lbDelete.Controls.Add(buttonIcon); lbDelete.Click += lbDelete_Click; lbDelete.DataBinding += lbDelete_DataBinding; // make sure delete button is registered for async postback (needed just in case the grid was created at runtime) var sm = ScriptManager.GetCurrent(this.ParentGrid.Page); sm.RegisterAsyncPostBackControl(lbDelete); cell.Controls.Add(lbDelete); } }
/// <summary> /// Handles the RowDataBound event of the gRecordings 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 gRecordings_RowDataBound(object sender, GridViewRowEventArgs e) { if (_canEdit) { Recording recording = e.Row.DataItem as Recording; LinkButton lbStart = (LinkButton)e.Row.FindControl("lbStart"); LinkButton lbStop = (LinkButton)e.Row.FindControl("lbStop"); if (recording != null && lbStart != null && lbStop != null) { lbStart.Enabled = !recording.StartTime.HasValue && !recording.StopTime.HasValue; lbStop.Enabled = recording.StartTime.HasValue && !recording.StopTime.HasValue; if (lbStart.Enabled) { lbStart.RemoveCssClass("disabled"); } else { lbStart.AddCssClass("disabled"); } if (lbStop.Enabled) { lbStop.RemoveCssClass("disabled"); } else { lbStop.AddCssClass("disabled"); } } } }
/// <summary> /// Handles the DataBinding event of the lbDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void lbDelete_DataBinding(object sender, EventArgs e) { if (ParentGrid.HideDeleteButtonForIsSystem) { LinkButton lbDelete = sender as LinkButton; GridViewRow dgi = lbDelete.NamingContainer as GridViewRow; if (dgi.DataItem != null) { PropertyInfo pi = dgi.DataItem.GetType().GetProperty("IsSystem"); if (pi != null) { bool isSystem = (bool)pi.GetValue(dgi.DataItem); if (isSystem) { lbDelete.AddCssClass("disabled"); lbDelete.Enabled = false; } } } } GridViewRow row = ( GridViewRow )(( LinkButton )sender).Parent.Parent; RowEventArgs args = new RowEventArgs(row); this.DeleteField.HandleOnDataBound(sender, args); }
protected void gvPackageVersions_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { IPackage package = e.Row.DataItem as IPackage; if (package != null) { Boolean isExactPackageInstalled = NuGetService.IsPackageInstalled(package); LinkButton lbInstall = e.Row.FindControl("lbInstall") as LinkButton; LinkButton lbUpdate = e.Row.FindControl("lbUpdate") as LinkButton; HtmlGenericControl iInstalledIcon = e.Row.FindControl("iInstalledIcon") as HtmlGenericControl; if (e.Row.RowIndex == 0) { lbInstall.AddCssClass("btn-primary"); } lbInstall.CommandArgument = lbUpdate.CommandArgument = e.Row.RowIndex.ToString(); // Don't show the install button if a version of this package is already installed lbInstall.Visible = (!lbPackageUninstall.Visible); // Show the update button if an older version of this package is already installed and the package is the latest version lbUpdate.Visible = ((lbPackageUninstall.Visible && !isExactPackageInstalled) && package.IsLatestVersion); iInstalledIcon.Visible = (isExactPackageInstalled); } } }
/// <summary> /// Enables and sets the appropriate CSS class on the install buttons and each div panel. /// </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 rptPackageVersions_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var package = e.Item.DataItem as RockRelease; if (package != null) { LinkButton lbInstall = e.Item.FindControl("lbInstall") as LinkButton; var divPanel = e.Item.FindControl("divPanel") as HtmlGenericControl; if ((package.RequiresVersion.IsNotNullOrWhiteSpace() && new Version(package.RequiresVersion) <= _installedVersion) || (package.RequiresVersion.IsNullOrWhiteSpace() && new Version(package.SemanticVersion) > _installedVersion)) { var release = _releases.Where(r => r.Version == package.Version.ToString()).FirstOrDefault(); if (!_isEarlyAccessOrganization && release != null && release.RequiresEarlyAccess) { lbInstall.Enabled = false; lbInstall.Text = "Available to Early<br/>Access Organizations"; lbInstall.AddCssClass("btn-warning"); divPanel.AddCssClass("panel-block"); } else { lbInstall.Enabled = true; lbInstall.AddCssClass("btn-info"); divPanel.AddCssClass("panel-info"); } } else { lbInstall.Enabled = false; lbInstall.Text = "Pending"; lbInstall.AddCssClass("btn-default"); divPanel.AddCssClass("panel-block"); } if (!_isOkToProceed || !VersionValidationHelper.CanInstallVersion(new Version(package.SemanticVersion))) { lbInstall.Enabled = false; lbInstall.AddCssClass("btn-danger"); lbInstall.AddCssClass("small"); lbInstall.AddCssClass("btn-xs"); lbInstall.Text = "Requirements not met"; } else if (package.PackageUri.IsNullOrWhiteSpace()) { lbInstall.Enabled = false; lbInstall.AddCssClass("small"); lbInstall.AddCssClass("btn-xs"); lbInstall.Text = "Package doesn't exists."; } // If any packages can be installed we need to show the backup message. nbBackupMessage.Visible = nbBackupMessage.Visible || lbInstall.Enabled; } } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); toggleAllAny = new Toggle(); Controls.Add(toggleAllAny); toggleAllAny.ID = this.ID + "_toggleAllAny"; toggleAllAny.ButtonSizeCssClass = "btn-xs"; toggleAllAny.OnText = "All"; toggleAllAny.OffText = "Any"; toggleAllAny.ActiveButtonCssClass = "btn-info"; toggleTrueFalse = new Toggle(); Controls.Add(toggleTrueFalse); toggleTrueFalse.ID = this.ID + "_toggleTrueFalse"; toggleTrueFalse.ButtonSizeCssClass = "btn-xs"; toggleTrueFalse.OnText = "True"; toggleTrueFalse.OffText = "False"; toggleTrueFalse.ActiveButtonCssClass = "btn-info"; btnAddGroup = new LinkButton(); Controls.Add(btnAddGroup); btnAddGroup.ID = this.ID + "_btnAddGroup"; btnAddGroup.Click += btnAddGroup_ServerClick; btnAddGroup.AddCssClass("btn btn-action"); btnAddGroup.CausesValidation = false; var iAddGroup = new HtmlGenericControl("i"); iAddGroup.AddCssClass("fa fa-list-alt"); btnAddGroup.Controls.Add(iAddGroup); btnAddGroup.Controls.Add(new LiteralControl(" Add Filter Group")); btnAddFilter = new LinkButton(); Controls.Add(btnAddFilter); btnAddFilter.ID = this.ID + "_btnAddFilter"; btnAddFilter.Click += btnAddFilter_ServerClick; btnAddFilter.AddCssClass("btn btn-action"); btnAddFilter.CausesValidation = false; var iAddFilter = new HtmlGenericControl("i"); iAddFilter.AddCssClass("fa fa-filter"); btnAddFilter.Controls.Add(iAddFilter); btnAddFilter.Controls.Add(new LiteralControl(" Add Filter")); lbDelete = new LinkButton(); Controls.Add(lbDelete); lbDelete.ID = this.ID + "_lbDelete"; lbDelete.Click += lbDelete_Click; lbDelete.AddCssClass("btn btn-sm btn-danger btn-square"); lbDelete.CausesValidation = false; var iDeleteGroup = new HtmlGenericControl("i"); iDeleteGroup.AddCssClass("fa fa-times"); lbDelete.Controls.Add(iDeleteGroup); }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _noteEditor = new NoteEditor(); _noteEditor.SetNoteOptions(this.NoteOptions); _noteEditor.ID = this.ID + "_noteEditor"; _noteEditor.CssClass = "note-new"; _noteEditor.CreatedByPersonAlias = (this.Page as RockPage)?.CurrentPersonAlias; _noteEditor.SaveButtonClick += note_SaveButtonClick; Controls.Add(_noteEditor); // Create a hidden field that javascript will populate with the selected note _hfCurrentNoteId = new HiddenFieldWithClass(); _hfCurrentNoteId.ID = this.ID + "_hfCurrentNoteId"; _hfCurrentNoteId.CssClass = "js-currentnoteid"; Controls.Add(_hfCurrentNoteId); _hfExpandedNoteIds = new HiddenFieldWithClass(); _hfExpandedNoteIds.ID = this.ID + "_hfExpandedNoteIds"; _hfExpandedNoteIds.CssClass = "js-expandednoteids"; Controls.Add(_hfExpandedNoteIds); // Create a hidden DeleteNote linkbutton that will hookup to the Lava'd Delete button _lbDeleteNote = new LinkButton(); _lbDeleteNote.ID = this.ID + "_lbDeleteNote"; _lbDeleteNote.CssClass = "js-delete-postback"; _lbDeleteNote.Click += _lbDeleteNote_Click; _lbDeleteNote.Style[HtmlTextWriterStyle.Display] = "none"; Controls.Add(_lbDeleteNote); _mdDeleteWarning = new ModalAlert(); _mdDeleteWarning.ID = this.ID + "_mdDeleteWarning"; Controls.Add(_mdDeleteWarning); _lbShowMore = new LinkButton(); _lbShowMore.ID = "lbShowMore"; _lbShowMore.Click += _lbShowMore_Click; _lbShowMore.AddCssClass("load-more btn btn-xs btn-action"); Controls.Add(_lbShowMore); var iDownPre = new HtmlGenericControl("i"); iDownPre.Attributes.Add("class", "fa fa-angle-down"); _lbShowMore.Controls.Add(iDownPre); var spanDown = new HtmlGenericControl("span"); spanDown.InnerHtml = " Load More "; _lbShowMore.Controls.Add(spanDown); var iDownPost = new HtmlGenericControl("i"); iDownPost.Attributes.Add("class", "fa fa-angle-down"); _lbShowMore.Controls.Add(iDownPost); }
/// <summary> /// When implemented by a class, defines the <see cref="T:System.Web.UI.Control"/> object that child controls and templates belong to. These child controls are in turn defined within an inline template. /// </summary> /// <param name="container">The <see cref="T:System.Web.UI.Control"/> object to contain the instances of controls from the inline template.</param> public void InstantiateIn(Control container) { DataControlFieldCell cell = container as DataControlFieldCell; if (cell != null) { DeleteField deleteField = cell.ContainingField as DeleteField; this.DeleteField = deleteField; // only need to do this stuff if the deleteField is actually going to be rendered onto the page if (deleteField.Visible) { ParentGrid = deleteField.ParentGrid; LinkButton lbDelete = new LinkButton(); lbDelete.CausesValidation = false; lbDelete.CssClass = deleteField.ButtonCssClass; lbDelete.PreRender += (s, e) => { if (lbDelete.Enabled) { if (!ParentGrid.Enabled || !ParentGrid.IsDeleteEnabled) { lbDelete.AddCssClass("disabled"); lbDelete.Enabled = false; } if (lbDelete.Enabled) { // if the lbDelete button is Enabled, make sure delete button is registered for async postback (needed just in case the grid was created at runtime) var sm = ScriptManager.GetCurrent(this.ParentGrid.Page); // note: this get's slower and slower when the Grid has lots of rows (for example on an Export), so it would be nice to figure out if this is needed sm.RegisterAsyncPostBackControl(lbDelete); } } }; lbDelete.ToolTip = deleteField.Tooltip; HtmlGenericControl buttonIcon = new HtmlGenericControl("i"); buttonIcon.Attributes.Add("class", deleteField.IconCssClass); lbDelete.Controls.Add(buttonIcon); lbDelete.Click += lbDelete_Click; lbDelete.DataBinding += lbDelete_DataBinding; cell.Controls.Add(lbDelete); } } }
/// <summary> /// Enables and sets the appropriate CSS class on the install buttons and each div panel. /// </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 rptPackageVersions_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { IPackage package = e.Item.DataItem as IPackage; if (package != null) { LinkButton lbInstall = e.Item.FindControl("lbInstall") as LinkButton; var divPanel = e.Item.FindControl("divPanel") as HtmlGenericControl; var requiredVersion = ExtractRequiredVersionFromTags(package); if (requiredVersion <= _installedVersion) { lbInstall.Enabled = true; lbInstall.AddCssClass("btn-info"); divPanel.AddCssClass("panel-info"); } else { lbInstall.Enabled = false; lbInstall.Text = "Pending"; lbInstall.AddCssClass("btn-default"); divPanel.AddCssClass("panel-block"); } if (!_isOkToProceed) { lbInstall.Enabled = false; lbInstall.AddCssClass("btn-danger"); lbInstall.AddCssClass("small"); lbInstall.AddCssClass("btn-xs"); lbInstall.Text = "Requirements not met"; } } } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); phExternalLogins.Controls.Clear(); // Look for active external authentication providers foreach (var serviceEntry in AuthenticationContainer.Instance.Components) { var component = serviceEntry.Value.Value; if (component.IsActive && component.RequiresRemoteAuthentication) { string loginTypeName = component.GetType().Name; // Check if returning from third-party authentication if (!IsPostBack && component.IsReturningFromAuthentication(Request)) { string userName = string.Empty; string returnUrl = string.Empty; if (component.Authenticate(Request, out userName, out returnUrl)) { LoginUser(userName, returnUrl, false); break; } } LinkButton lbLogin = new LinkButton(); phExternalLogins.Controls.Add(lbLogin); lbLogin.AddCssClass("btn btn-authenication " + loginTypeName.ToLower()); lbLogin.ID = "lb" + loginTypeName + "Login"; lbLogin.Click += lbLogin_Click; lbLogin.CausesValidation = false; if (!String.IsNullOrWhiteSpace(component.ImageUrl())) { HtmlImage img = new HtmlImage(); lbLogin.Controls.Add(img); img.Attributes.Add("style", "border:none"); img.Src = Page.ResolveUrl(component.ImageUrl()); } else { lbLogin.Text = "Login Using " + loginTypeName; } } } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _lbAddFamilyMember = new LinkButton(); Controls.Add(_lbAddFamilyMember); _lbAddFamilyMember.ID = this.ID + "_btnAddFamilyMember"; _lbAddFamilyMember.Click += lbAddFamilyMember_Click; _lbAddFamilyMember.AddCssClass("add btn btn-action"); _lbAddFamilyMember.CausesValidation = false; var iAddFilter = new HtmlGenericControl("i"); iAddFilter.AddCssClass("fa fa-plus-circle"); _lbAddFamilyMember.Controls.Add(iAddFilter); }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _lbAddGroupMember = new LinkButton(); Controls.Add(_lbAddGroupMember); _lbAddGroupMember.ID = this.ID + "_btnAddGroupMember"; _lbAddGroupMember.Click += lbAddGroupMember_Click; _lbAddGroupMember.AddCssClass("add btn btn-xs btn-action pull-right"); _lbAddGroupMember.CausesValidation = false; var iAddFilter = new HtmlGenericControl("i"); iAddFilter.AddCssClass("fa fa-user"); _lbAddGroupMember.Controls.Add(iAddFilter); var spanAddFilter = new HtmlGenericControl("span"); spanAddFilter.InnerHtml = " Add Person"; _lbAddGroupMember.Controls.Add(spanAddFilter); }
/// <summary> /// Handles the DataBinding event of the lbDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void lbDelete_DataBinding(object sender, EventArgs e) { if (ParentGrid.HideDeleteButtonForIsSystem) { LinkButton lbDelete = sender as LinkButton; GridViewRow dgi = lbDelete.NamingContainer as GridViewRow; if (dgi.DataItem != null) { PropertyInfo pi = dgi.DataItem.GetType().GetProperty("IsSystem"); if (pi != null) { bool isSystem = (bool)pi.GetValue(dgi.DataItem); if (isSystem) { lbDelete.AddCssClass("disabled"); lbDelete.Enabled = false; } } } } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _lbAddChild = new LinkButton(); Controls.Add(_lbAddChild); _lbAddChild.ID = "_btnAddChild"; _lbAddChild.Click += lbAddChild_Click; _lbAddChild.AddCssClass("add btn btn-xs btn-default pull-right"); _lbAddChild.CausesValidation = false; var iAddFilter = new HtmlGenericControl("i"); iAddFilter.AddCssClass("fa fa-user"); _lbAddChild.Controls.Add(iAddFilter); var spanAddFilter = new HtmlGenericControl("span"); spanAddFilter.InnerHtml = " Add Child"; _lbAddChild.Controls.Add(spanAddFilter); }
/// <summary> /// Enables and sets the appropriate CSS class on the install buttons and each div panel. /// </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 rptPackageVersions_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { IPackage package = e.Item.DataItem as IPackage; if (package != null) { LinkButton lbInstall = e.Item.FindControl("lbInstall") as LinkButton; var divPanel = e.Item.FindControl("divPanel") as HtmlGenericControl; var requiredVersion = ExtractRequiredVersionFromTags(package); if (requiredVersion <= _installedVersion) { var release = _releases.Where(r => r.SemanticVersion == package.Version.ToString()).FirstOrDefault(); if (!_isEarlyAccessOrganization && release != null && release.RequiresEarlyAccess) { lbInstall.Enabled = false; lbInstall.Text = "Available to Early<br/>Access Organizations"; lbInstall.AddCssClass("btn-warning"); divPanel.AddCssClass("panel-block"); } else { lbInstall.Enabled = true; lbInstall.AddCssClass("btn-info"); divPanel.AddCssClass("panel-info"); } } else { lbInstall.Enabled = false; lbInstall.Text = "Pending"; lbInstall.AddCssClass("btn-default"); divPanel.AddCssClass("panel-block"); } if (!_isOkToProceed || !CanInstallVersion(package.Version)) { lbInstall.Enabled = false; lbInstall.AddCssClass("btn-danger"); lbInstall.AddCssClass("small"); lbInstall.AddCssClass("btn-xs"); lbInstall.Text = "Requirements not met"; } } } }
/// <summary> /// Handles the ItemDataBound event of the rptSelectTemplate 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 rptSelectTemplate_ItemDataBound(object sender, RepeaterItemEventArgs e) { CommunicationTemplate communicationTemplate = e.Item.DataItem as CommunicationTemplate; if (communicationTemplate != null) { Literal lTemplateImagePreview = e.Item.FindControl("lTemplateImagePreview") as Literal; Literal lTemplateName = e.Item.FindControl("lTemplateName") as Literal; Literal lTemplateDescription = e.Item.FindControl("lTemplateDescription") as Literal; LinkButton btnSelectTemplate = e.Item.FindControl("btnSelectTemplate") as LinkButton; if (communicationTemplate.ImageFileId.HasValue) { var imageUrl = string.Format("~/GetImage.ashx?id={0}", communicationTemplate.ImageFileId); lTemplateImagePreview.Text = string.Format("<img src='{0}' width='100%'/>", this.ResolveRockUrl(imageUrl)); } else { lTemplateImagePreview.Text = string.Format("<img src='{0}'/>", this.ResolveRockUrl("~/Assets/Images/communication-template-default.svg")); } lTemplateName.Text = communicationTemplate.Name; lTemplateDescription.Text = communicationTemplate.Description; btnSelectTemplate.CommandName = "CommunicationTemplateId"; btnSelectTemplate.CommandArgument = communicationTemplate.Id.ToString(); if (hfSelectedCommunicationTemplateId.Value == communicationTemplate.Id.ToString()) { btnSelectTemplate.AddCssClass("template-selected"); } else { btnSelectTemplate.RemoveCssClass("template-selected"); } } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); btnNewAccount.Visible = !GetAttributeValue("HideNewAccount").AsBoolean(); phExternalLogins.Controls.Clear(); int activeAuthProviders = 0; var selectedGuids = new List <Guid>(); GetAttributeValue("RemoteAuthorizationTypes").SplitDelimitedValues() .ToList() .ForEach(v => selectedGuids.Add(v.AsGuid())); // Look for active external authentication providers foreach (var serviceEntry in AuthenticationContainer.Instance.Components) { var component = serviceEntry.Value.Value; if (component.IsActive && component.RequiresRemoteAuthentication && selectedGuids.Contains(component.EntityType.Guid)) { string loginTypeName = component.GetType().Name; // Check if returning from third-party authentication if (!IsPostBack && component.IsReturningFromAuthentication(Request)) { string userName = string.Empty; string returnUrl = string.Empty; string redirectUrlSetting = LinkedPageUrl("RedirectPage"); if (component.Authenticate(Request, out userName, out returnUrl)) { if (!string.IsNullOrWhiteSpace(redirectUrlSetting)) { LoginUser(userName, redirectUrlSetting, false); break; } else { LoginUser(userName, returnUrl, false); break; } } } activeAuthProviders++; LinkButton lbLogin = new LinkButton(); phExternalLogins.Controls.Add(lbLogin); lbLogin.AddCssClass("btn btn-authenication " + loginTypeName.ToLower()); lbLogin.ID = "lb" + loginTypeName + "Login"; lbLogin.Click += lbLogin_Click; lbLogin.CausesValidation = false; if (!string.IsNullOrWhiteSpace(component.ImageUrl())) { HtmlImage img = new HtmlImage(); lbLogin.Controls.Add(img); img.Attributes.Add("style", "border:none"); img.Src = Page.ResolveUrl(component.ImageUrl()); } else { lbLogin.Text = loginTypeName; } } } // adjust the page if there are no social auth providers if (activeAuthProviders == 0) { divSocialLogin.Visible = false; divOrgLogin.RemoveCssClass("col-sm-6"); divOrgLogin.AddCssClass("col-sm-12"); } }
/// <summary> /// Adds the admin controls. /// </summary> /// <param name="block">The block.</param> /// <param name="pnlLayoutItem">The PNL layout item.</param> private void AddAdminControls(BlockCache block, PlaceHolder pnlLayoutItem) { Panel pnlAdminButtons = new Panel { ID = "pnlBlockConfigButtons", CssClass = "pull-right actions" }; // Block Properties var btnBlockProperties = new Literal { Text = string.Format(@"<a title='Block Properties' class='btn btn-sm btn-default btn-square properties' href='javascript: Rock.controls.modal.show($(this), ""/BlockProperties/{0}?t=Block Properties"")' height='500px'><i class='fa fa-cog'></i></a>", block.Id) }; pnlAdminButtons.Controls.Add(btnBlockProperties); // Block Security int entityTypeBlockId = EntityTypeCache.Get <Rock.Model.Block>().Id; var btnBlockSecurity = new SecurityButton { ID = "btnBlockSecurity", EntityTypeId = entityTypeBlockId, EntityId = block.Id, Title = "Edit Security" }; btnBlockSecurity.AddCssClass("btn btn-sm btn-square btn-security"); pnlAdminButtons.Controls.Add(btnBlockSecurity); // Delete Block LinkButton btnDeleteBlock = new LinkButton { ID = string.Format("btnDeleteBlock_{0}", block.Id), CommandName = "Delete", CommandArgument = block.Id.ToString(), CssClass = "btn btn-sm btn-square btn-danger", Text = "<i class='fa fa-times'></i>", ToolTip = "Delete Block" }; btnDeleteBlock.Attributes["onclick"] = string.Format("javascript: return Rock.dialogs.confirmDelete(event, '{0}');", Block.FriendlyTypeName); pnlAdminButtons.Controls.Add(btnDeleteBlock); pnlLayoutItem.Controls.Add(pnlAdminButtons); RockBlock blockControl = null; IEnumerable <WebControl> customAdminControls = new List <WebControl>(); try { if (!string.IsNullOrWhiteSpace(block.BlockType.Path)) { blockControl = TemplateControl.LoadControl(block.BlockType.Path) as RockBlock; } else if (block.BlockType.EntityTypeId.HasValue) { var blockEntity = Activator.CreateInstance(block.BlockType.EntityType.GetEntityType()); var wrapper = new RockBlockTypeWrapper { Page = RockPage, Block = (Rock.Blocks.IRockBlockType)blockEntity }; wrapper.InitializeAsUserControl(RockPage); wrapper.AppRelativeTemplateSourceDirectory = "~"; blockControl = wrapper; } blockControl.SetBlock(block.Page, block, true, true); var adminControls = blockControl.GetAdministrateControls(true, true); string[] baseAdminControlClasses = new string[4] { "properties", "security", "block-move", "block-delete" }; customAdminControls = adminControls.OfType <WebControl>().Where(a => !baseAdminControlClasses.Any(b => a.CssClass.Contains(b))); } catch (Exception ex) { // if the block doesn't compile, just ignore it since we are just trying to get the admin controls Literal lblBlockError = new Literal(); lblBlockError.Text = string.Format("<span class='label label-danger'>ERROR: {0}</span>", ex.Message); pnlLayoutItem.Controls.Add(lblBlockError); } foreach (var customAdminControl in customAdminControls) { if (customAdminControl is LinkButton) { LinkButton btn = customAdminControl as LinkButton; if (btn != null) { // ensure custom link button looks like a button btn.AddCssClass("btn"); btn.AddCssClass("btn-sm"); btn.AddCssClass("btn-default"); btn.AddCssClass("btn-square"); // some admincontrols will toggle the BlockConfig bar, but this isn't a block config bar, so remove the javascript if (btn.Attributes["onclick"] != null) { btn.Attributes["onclick"] = btn.Attributes["onclick"].Replace("Rock.admin.pageAdmin.showBlockConfig()", string.Empty); } } } pnlLayoutItem.Controls.Add(customAdminControl); } if (customAdminControls.Any() && blockControl != null) { pnlBlocksHolder.Controls.Add(blockControl); } }
/// <summary> /// Applies the block settings. /// </summary> private void ApplyBlockSettings() { btnNewAccount.Visible = !GetAttributeValue("HideNewAccount").AsBoolean(); btnNewAccount.Text = this.GetAttributeValue("NewAccountButtonText") ?? "Register"; phExternalLogins.Controls.Clear(); List <AuthenticationComponent> activeAuthProviders = new List <AuthenticationComponent>(); var selectedGuids = new List <Guid>(); GetAttributeValue("RemoteAuthorizationTypes").SplitDelimitedValues() .ToList() .ForEach(v => selectedGuids.Add(v.AsGuid())); lRemoteAuthLoginsHeadingText.Text = this.GetAttributeValue("RemoteAuthorizationPromptMessage"); // Look for active external authentication providers foreach (var serviceEntry in AuthenticationContainer.Instance.Components) { var component = serviceEntry.Value.Value; if (component.IsActive && component.RequiresRemoteAuthentication && selectedGuids.Contains(component.EntityType.Guid)) { string loginTypeName = component.GetType().Name; // Check if returning from third-party authentication if (!IsPostBack && component.IsReturningFromAuthentication(Request)) { string userName = string.Empty; string returnUrl = string.Empty; string redirectUrlSetting = LinkedPageUrl("RedirectPage"); if (component.Authenticate(Request, out userName, out returnUrl)) { if (!string.IsNullOrWhiteSpace(redirectUrlSetting)) { CheckUser(userName, redirectUrlSetting, true); break; } else { CheckUser(userName, returnUrl, true); break; } } } activeAuthProviders.Add(component); LinkButton lbLogin = new LinkButton(); phExternalLogins.Controls.Add(lbLogin); lbLogin.AddCssClass("btn btn-authentication " + component.LoginButtonCssClass); lbLogin.ID = "lb" + loginTypeName + "Login"; lbLogin.Click += lbLogin_Click; lbLogin.CausesValidation = false; if (!string.IsNullOrWhiteSpace(component.ImageUrl())) { HtmlImage img = new HtmlImage(); lbLogin.Controls.Add(img); img.Attributes.Add("style", "border:none"); img.Src = Page.ResolveUrl(component.ImageUrl()); } lbLogin.Text = component.LoginButtonText; } } // adjust the page layout based on the RemoteAuth and InternalLogin options pnlRemoteAuthLogins.Visible = activeAuthProviders.Any(); bool showInternalLogin = this.GetAttributeValue("ShowInternalLogin").AsBooleanOrNull() ?? true; pnlInternalAuthLogin.Visible = showInternalLogin; if (activeAuthProviders.Count() == 1 && !showInternalLogin) { var singleAuthProvider = activeAuthProviders[0]; bool redirecttoSingleExternalAuthProvider = this.GetAttributeValue("RedirecttoSingleExternalAuthProvider").AsBoolean(); if (redirecttoSingleExternalAuthProvider) { Uri remoteAuthLoginUri = singleAuthProvider.GenerateLoginUrl(this.Request); if (remoteAuthLoginUri != null) { if (IsUserAuthorized(Rock.Security.Authorization.ADMINISTRATE)) { nbAdminRedirectPrompt.Text = string.Format("If you did not have Administrate permissions on this block, you would have been redirected to the <a href='{0}'>{1}</a> url.", remoteAuthLoginUri.AbsoluteUri, singleAuthProvider.LoginButtonText); nbAdminRedirectPrompt.Visible = true; } else { Response.Redirect(remoteAuthLoginUri.AbsoluteUri, false); Context.ApplicationInstance.CompleteRequest(); return; } } } } if (pnlInternalAuthLogin.Visible && pnlRemoteAuthLogins.Visible) { // if they are both visible, show in 2 equal columns pnlRemoteAuthLogins.CssClass = "col-sm-6 margin-b-lg"; pnlInternalAuthLogin.CssClass = "col-sm-6"; } else { // if only one (or none) is visible, show in one column pnlRemoteAuthLogins.CssClass = "col-sm-12 margin-b-lg"; pnlInternalAuthLogin.CssClass = "col-sm-12"; } }
/// <summary> /// Adds the admin controls. /// </summary> /// <param name="block">The block.</param> /// <param name="pnlLayoutItem">The PNL layout item.</param> private void AddAdminControls(BlockCache block, Panel pnlLayoutItem) { Panel pnlAdminButtons = new Panel { ID = "pnlBlockConfigButtons", CssClass = "pull-right actions" }; // Block Properties Literal btnBlockProperties = new Literal(); btnBlockProperties.Text = string.Format(@"<a title='Block Properties' class='btn btn-sm btn-default properties' id='aBlockProperties' href='javascript: Rock.controls.modal.show($(this), ""/BlockProperties/{0}?t=Block Properties"")' height='500px'><i class='fa fa-cog'></i></a>", block.Id); pnlAdminButtons.Controls.Add(btnBlockProperties); // Block Security int entityTypeBlockId = EntityTypeCache.Read <Rock.Model.Block>().Id; SecurityButton btnBlockSecurity = new SecurityButton { ID = "btnBlockSecurity", EntityTypeId = entityTypeBlockId, EntityId = block.Id, Title = block.Name }; btnBlockSecurity.AddCssClass("btn btn-sm btn-security"); pnlAdminButtons.Controls.Add(btnBlockSecurity); // Move Block LinkButton btnMoveBlock = new LinkButton(); btnMoveBlock.ID = string.Format("btnMoveBlock_{0}", block.Id); btnMoveBlock.CommandName = "BlockId"; btnMoveBlock.CommandArgument = block.Id.ToString(); btnMoveBlock.CssClass = "btn btn-sm btn-default fa fa-external-link"; btnMoveBlock.ToolTip = "Move Block"; btnMoveBlock.Click += btnMoveBlock_Click; pnlAdminButtons.Controls.Add(btnMoveBlock); // Delete Block LinkButton btnDeleteBlock = new LinkButton(); btnDeleteBlock.ID = string.Format("btnDeleteBlock_{0}", block.Id); btnDeleteBlock.CommandName = "BlockId"; btnDeleteBlock.CommandArgument = block.Id.ToString(); btnDeleteBlock.CssClass = "btn btn-xs btn-danger"; btnDeleteBlock.Text = "<i class='fa fa-times'></i>"; btnDeleteBlock.ToolTip = "Delete Block"; btnDeleteBlock.Click += btnDeleteBlock_Click; btnDeleteBlock.Attributes["onclick"] = string.Format("javascript: return Rock.dialogs.confirmDelete(event, '{0}');", Block.FriendlyTypeName); pnlAdminButtons.Controls.Add(btnDeleteBlock); pnlLayoutItem.Controls.Add(pnlAdminButtons); RockBlock blockControl = null; IEnumerable <WebControl> customAdminControls = new List <WebControl>(); try { blockControl = this.Page.TemplateControl.LoadControl(block.BlockType.Path) as RockBlock; blockControl.SetBlock(block.Page, block, true, true); var adminControls = blockControl.GetAdministrateControls(true, true); string[] baseAdminControlClasses = new string[4] { "properties", "security", "block-move", "block-delete" }; customAdminControls = adminControls.OfType <WebControl>().Where(a => !baseAdminControlClasses.Any(b => a.CssClass.Contains(b))); } catch (Exception ex) { // if the block doesn't compile, just ignore it since we are just trying to get the admin controls Literal lblBlockError = new Literal(); lblBlockError.Text = string.Format("<span class='label label-danger'>ERROR: {0}</span>", ex.Message); pnlLayoutItem.Controls.Add(lblBlockError); } foreach (var customAdminControl in customAdminControls) { if (customAdminControl is LinkButton) { LinkButton btn = customAdminControl as LinkButton; if (btn != null) { // ensure custom link button looks like a button btn.AddCssClass("btn"); btn.AddCssClass("btn-sm"); btn.AddCssClass("btn-default"); // some admincontrols will toggle the BlockConfig bar, but this isn't a block config bar, so remove the javascript if (btn.Attributes["onclick"] != null) { btn.Attributes["onclick"] = btn.Attributes["onclick"].Replace("Rock.admin.pageAdmin.showBlockConfig()", string.Empty); } } } pnlLayoutItem.Controls.Add(customAdminControl); } if (customAdminControls.Any() && blockControl != null) { pnlBlocksHolder.Controls.Add(blockControl); } }
private void CreateControls(bool setSelection) { // Load all the attribute controls attributeControls.Clear(); pnlAttributes.Controls.Clear(); phDuplicates.Controls.Clear(); var rockContext = new RockContext(); var attributeService = new AttributeService(rockContext); var locationService = new LocationService(rockContext); foreach (string categoryGuid in GetAttributeValue("AttributeCategories").SplitDelimitedValues(false)) { Guid guid = Guid.Empty; if (Guid.TryParse(categoryGuid, out guid)) { var category = CategoryCache.Read(guid); if (category != null) { var attributeControl = new NewFamilyAttributes(); attributeControl.ClearRows(); pnlAttributes.Controls.Add(attributeControl); attributeControls.Add(attributeControl); attributeControl.ID = "familyAttributes_" + category.Id.ToString(); attributeControl.CategoryId = category.Id; foreach (var attribute in attributeService.GetByCategoryId(category.Id)) { if (attribute.IsAuthorized(Authorization.EDIT, CurrentPerson)) { attributeControl.AttributeList.Add(AttributeCache.Read(attribute)); } } } } } nfmMembers.ClearRows(); nfciContactInfo.ClearRows(); var groupMemberService = new GroupMemberService(rockContext); var familyGroupType = GroupTypeCache.GetFamilyGroupType(); int adultRoleId = familyGroupType.Roles.First(a => a.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid()).Id; var homeLocationGuid = Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid(); var location = locationService.Get(acAddress.Street1, acAddress.Street2, acAddress.City, acAddress.State, acAddress.PostalCode, acAddress.Country); foreach (var familyMember in FamilyMembers) { string familyMemberGuidString = familyMember.Person.Guid.ToString().Replace("-", "_"); var familyMemberRow = new NewFamilyMembersRow(); nfmMembers.Controls.Add(familyMemberRow); familyMemberRow.ID = string.Format("row_{0}", familyMemberGuidString); familyMemberRow.RoleUpdated += familyMemberRow_RoleUpdated; familyMemberRow.DeleteClick += familyMemberRow_DeleteClick; familyMemberRow.PersonGuid = familyMember.Person.Guid; familyMemberRow.RequireGender = nfmMembers.RequireGender; familyMemberRow.RequireGrade = nfmMembers.RequireGrade; familyMemberRow.RoleId = familyMember.GroupRoleId; familyMemberRow.ShowGrade = familyMember.GroupRoleId == _childRoleId; familyMemberRow.ValidationGroup = BlockValidationGroup; var contactInfoRow = new NewFamilyContactInfoRow(); nfciContactInfo.Controls.Add(contactInfoRow); contactInfoRow.ID = string.Format("ci_row_{0}", familyMemberGuidString); contactInfoRow.PersonGuid = familyMember.Person.Guid; contactInfoRow.IsMessagingEnabled = _SMSEnabled; contactInfoRow.PersonName = familyMember.Person.FullName; if (_homePhone != null) { var homePhoneNumber = familyMember.Person.PhoneNumbers.Where(p => p.NumberTypeValueId == _homePhone.Id).FirstOrDefault(); if (homePhoneNumber != null) { contactInfoRow.HomePhoneNumber = PhoneNumber.FormattedNumber(homePhoneNumber.CountryCode, homePhoneNumber.Number); contactInfoRow.HomePhoneCountryCode = homePhoneNumber.CountryCode; } } if (_cellPhone != null) { var cellPhoneNumber = familyMember.Person.PhoneNumbers.Where(p => p.NumberTypeValueId == _cellPhone.Id).FirstOrDefault(); if (cellPhoneNumber != null) { contactInfoRow.CellPhoneNumber = PhoneNumber.FormattedNumber(cellPhoneNumber.CountryCode, cellPhoneNumber.Number); contactInfoRow.CellPhoneCountryCode = cellPhoneNumber.CountryCode; } } contactInfoRow.Email = familyMember.Person.Email; if (setSelection) { if (familyMember.Person != null) { familyMemberRow.TitleValueId = familyMember.Person.TitleValueId; familyMemberRow.FirstName = familyMember.Person.FirstName; familyMemberRow.LastName = familyMember.Person.LastName; familyMemberRow.SuffixValueId = familyMember.Person.SuffixValueId; familyMemberRow.Gender = familyMember.Person.Gender; familyMemberRow.BirthDate = familyMember.Person.BirthDate; familyMemberRow.ConnectionStatusValueId = familyMember.Person.ConnectionStatusValueId; familyMemberRow.GradeOffset = familyMember.Person.GradeOffset; } } foreach (var attributeControl in attributeControls) { var attributeRow = new NewFamilyAttributesRow(); attributeControl.Controls.Add(attributeRow); attributeRow.ID = string.Format("{0}_{1}", attributeControl.ID, familyMemberGuidString); attributeRow.AttributeList = attributeControl.AttributeList; attributeRow.PersonGuid = familyMember.Person.Guid; attributeRow.PersonName = familyMember.Person.FullName; if (setSelection) { attributeRow.SetEditValues(familyMember.Person); } } if (Duplicates.ContainsKey(familyMember.Person.Guid)) { var dupRow = new HtmlGenericControl("div"); dupRow.AddCssClass("row"); dupRow.ID = string.Format("dupRow_{0}", familyMemberGuidString); phDuplicates.Controls.Add(dupRow); var newPersonCol = new HtmlGenericControl("div"); newPersonCol.AddCssClass("col-md-6"); newPersonCol.ID = string.Format("newPersonCol_{0}", familyMemberGuidString); dupRow.Controls.Add(newPersonCol); newPersonCol.Controls.Add(PersonHtmlPanel( familyMemberGuidString, familyMember.Person, familyMember.GroupRole, location, rockContext)); LinkButton lbRemoveMember = new LinkButton(); lbRemoveMember.ID = string.Format("lbRemoveMember_{0}", familyMemberGuidString); lbRemoveMember.AddCssClass("btn btn-danger btn-xs"); lbRemoveMember.Text = "Remove"; lbRemoveMember.Click += lbRemoveMember_Click; newPersonCol.Controls.Add(lbRemoveMember); var dupPersonCol = new HtmlGenericControl("div"); dupPersonCol.AddCssClass("col-md-6"); dupPersonCol.ID = string.Format("dupPersonCol_{0}", familyMemberGuidString); dupRow.Controls.Add(dupPersonCol); var duplicateHeader = new HtmlGenericControl("h4"); duplicateHeader.InnerText = "Possible Duplicate Records"; dupPersonCol.Controls.Add(duplicateHeader); foreach (var duplicate in Duplicates[familyMember.Person.Guid]) { GroupTypeRole groupTypeRole = null; Location duplocation = null; var familyGroupMember = groupMemberService.Queryable() .Where(a => a.PersonId == duplicate.Id) .Where(a => a.Group.GroupTypeId == familyGroupType.Id) .Select(s => new { s.GroupRole, GroupLocation = s.Group.GroupLocations.Where(a => a.GroupLocationTypeValue.Guid == homeLocationGuid).Select(a => a.Location).FirstOrDefault() }) .FirstOrDefault(); if (familyGroupMember != null) { groupTypeRole = familyGroupMember.GroupRole; duplocation = familyGroupMember.GroupLocation; } dupPersonCol.Controls.Add(PersonHtmlPanel( familyMemberGuidString, duplicate, groupTypeRole, duplocation, rockContext)); } } } ShowPage(); }
/// <summary> /// Builds table cells for the Exception Detail table and adds them to the table /// </summary> /// <param name="detailSummaries">List of Excpetion Detial Summary objects</param> private void BuildExceptionDetailTable(List <ExceptionDetailSummary> detailSummaries) { StringBuilder script = new StringBuilder(); foreach (var summary in detailSummaries) { string exceptionPageUrl = string.Format("/page/{0}?ExceptionId={1}", CurrentPage.Id, summary.ExceptionId); TableRow detailRow = new TableRow(); detailRow.ID = string.Format("tdRowExceptionDetail_{0}", summary.ExceptionId); TableCell exceptionTypeCell = new TableCell(); exceptionTypeCell.ID = string.Format("tcExceptionType_{0}", summary.ExceptionId); exceptionTypeCell.Text = summary.ExceptionType; detailRow.Cells.Add(exceptionTypeCell); TableCell exceptionSourceCell = new TableCell(); exceptionSourceCell.ID = string.Format("tcExceptionSource_{0}", summary.ExceptionId); exceptionSourceCell.Text = summary.ExceptionSource; detailRow.Cells.Add(exceptionSourceCell); TableCell exceptionDescriptionCell = new TableCell(); exceptionDescriptionCell.ID = string.Format("tcExceptionDetail_{0}", summary.ExceptionId); exceptionDescriptionCell.Text = summary.ExceptionDescription; detailRow.Cells.Add(exceptionDescriptionCell); TableCell exceptionStackTraceToggleCell = new TableCell(); exceptionStackTraceToggleCell.ID = string.Format("tcExceptionStackTraceToggle_{0}", summary.ExceptionId); LinkButton lbExceptionStackTrace = new LinkButton(); lbExceptionStackTrace.ID = string.Format("lbExceptionStackTraceToggle_{0}", summary.ExceptionId); lbExceptionStackTrace.Attributes.Add("onClick", string.Format("toggleStackTrace({0});return false;", summary.ExceptionId)); var iToggle = new HtmlGenericControl("i"); iToggle.AddCssClass("icon-file-alt"); lbExceptionStackTrace.Controls.Add(iToggle); var spanTitle = new HtmlGenericContainer("span"); spanTitle.ID = string.Format("spanExceptionStackTrace_{0}", summary.ExceptionId); spanTitle.InnerText = " Show Stack Trace"; lbExceptionStackTrace.Controls.Add(spanTitle); lbExceptionStackTrace.AddCssClass("btn"); exceptionStackTraceToggleCell.Controls.Add(lbExceptionStackTrace); exceptionStackTraceToggleCell.HorizontalAlign = HorizontalAlign.Center; detailRow.Cells.Add(exceptionStackTraceToggleCell); tblExceptionDetails.Rows.Add(detailRow); TableRow stackTraceRow = new TableRow(); stackTraceRow.CssClass = "exceptionDetail-stackTrace-hide"; stackTraceRow.ID = string.Format("tdRowExceptionStackTrace_{0}", summary.ExceptionId); TableCell exceptionStackTraceCell = new TableCell(); exceptionStackTraceCell.ID = string.Format("tdExceptionStackTrace_{0}", summary.ExceptionId); exceptionStackTraceCell.ColumnSpan = 4; exceptionStackTraceCell.Text = summary.StackTrace; exceptionStackTraceCell.HorizontalAlign = HorizontalAlign.Left; stackTraceRow.Cells.Add(exceptionStackTraceCell); tblExceptionDetails.Rows.Add(stackTraceRow); script.Append("$(\"[id*=" + exceptionSourceCell.ID + "]\").click(function () { redirectToPage(\"" + exceptionPageUrl + "\"); });"); script.Append("$(\"[id*=" + exceptionSourceCell.ID + "]\").click(function () { redirectToPage(\"" + exceptionPageUrl + "\"); });"); script.Append("$(\"[id*=" + exceptionDescriptionCell.ID + "]\").click(function () { redirectToPage(\"" + exceptionPageUrl + "\"); });"); script.Append("$(\"[id*=" + exceptionStackTraceCell.ID + "]\").click(function () { redirectToPage(\"" + exceptionPageUrl + "\"); });"); } if (!String.IsNullOrWhiteSpace(script.ToString())) { ScriptManager.RegisterStartupScript(upExcpetionDetail, upExcpetionDetail.GetType(), "ExceptionRedirects" + DateTime.Now.Ticks, script.ToString(), true); } }
/// <summary> /// Used to populate each item in the PackageList /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gPackageList_RowDataBound(object sender, GridViewRowEventArgs e) { IPackage package = e.Row.DataItem as IPackage; if (package != null) { Boolean isPackageInstalled = NuGetService.IsPackageInstalled(package, anyVersion: true); LinkButton lbCommand = e.Row.FindControl("lbCommand") as LinkButton; LinkButton lbUpdate = e.Row.FindControl("lbUpdate") as LinkButton; LinkButton lbView = e.Row.FindControl("lbView") as LinkButton; HtmlAnchor link = e.Row.FindControl("lProjectUrl") as HtmlAnchor; Literal lblAuthors = e.Row.FindControl("lblAuthors") as Literal; Literal lblVersion = e.Row.FindControl("lblVersion") as Literal; Literal lblLatestVersion = e.Row.FindControl("lblLatestVersion") as Literal; Literal lblInstalledVersion = e.Row.FindControl("lblInstalledVersion") as Literal; if (package.IconUrl != null) { Image imgIconUrl = e.Row.FindControl("imgIconUrl") as Image; imgIconUrl.ImageUrl = package.IconUrl.ToString();; } lblAuthors.Text = string.Join(",", package.Authors); if (package.ProjectUrl != null) { link.Visible = true; link.HRef = package.ProjectUrl.ToString(); } else { link.Visible = false; } lbUpdate.Visible = false; // If this package (not necessarily this version) is installed // show an uninstall button and/or an update button if a later version exists if (isPackageInstalled) { IPackage theInstalledPackage = NuGetService.GetInstalledPackage(package.Id); if (theInstalledPackage != null) { lblInstalledVersion.Visible = true; lblInstalledVersion.Text += theInstalledPackage.Version; try { // Checking "IsLatestVersion" does not work because of what's discussed here: // http://nuget.codeplex.com/discussions/279837 // if ( !installedPackage.IsLatestVersion )... var latestPackage = NuGetService.GetUpdate(package); if (latestPackage != null) { lbUpdate.Visible = true; lblLatestVersion.Visible = true; lblLatestVersion.Text += latestPackage.Version; } } catch (InvalidOperationException ex) { Literal lblItemError = e.Row.FindControl("lblItemError") as Literal; lblItemError.Text = string.Format("<p class='text-error'>We're having a problem... {0}</p>", ex.Message); } } lbCommand.CommandName = "uninstall"; lbCommand.Text = "<i class='fa fa-times'></i> Uninstall"; lbCommand.AddCssClass("btn-warning"); } else { lblVersion.Visible = true; lblVersion.Text += package.Version; lbCommand.CommandName = "Install"; lbCommand.Text = "<i class='fa fa-download'></i> Install"; } lbCommand.CommandArgument = lbUpdate.CommandArgument = lbView.CommandArgument = e.Row.RowIndex.ToString(); } }