/// <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) { SecurityField securityField = cell.ContainingField as SecurityField; HtmlGenericControl aSecure = new HtmlGenericControl("a"); cell.Controls.Add(aSecure); aSecure.Attributes.Add("class", securityField.ButtonCssClass); // height attribute is used by the modal that pops up when the button is clicked aSecure.Attributes.Add("height", "500px"); HtmlGenericControl buttonIcon = new HtmlGenericControl("i"); buttonIcon.Attributes.Add("class", securityField.IconCssClass); aSecure.Controls.Add(buttonIcon); aSecure.DataBinding += new EventHandler(aSecure_DataBinding); } }
/// <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 ); // set person context var contextEntity = this.ContextEntity(); if ( contextEntity != null ) { if ( contextEntity is Person ) { _person = contextEntity as Person; } } // set person if grid should be filtered by the current person if ( GetAttributeValue( "FilterItemsForCurrentUser" ).AsBoolean() ) { _person = CurrentPerson; } gfFilter.Visible = GetAttributeValue( "ShowFilters" ).AsBoolean(); _channelId = PageParameter( "contentChannelId" ).AsIntegerOrNull(); if ( _channelId != null ) { upnlContent.Visible = true; string cssIcon = "fa fa-bullhorn"; var contentChannel = new ContentChannelService( new RockContext() ).Get( _channelId.Value ); if ( contentChannel != null ) { string startHeading = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active"; bool isRange = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange; gItems.Columns[1].HeaderText = startHeading; gItems.Columns[3].HeaderText = startHeading; ddlStatus.Visible = contentChannel.RequiresApproval; if ( contentChannel.ContentChannelType.IncludeTime ) { gItems.Columns[1].Visible = true; gItems.Columns[2].Visible = isRange; gItems.Columns[3].Visible = false; gItems.Columns[4].Visible = false; } else { gItems.Columns[1].Visible = false; gItems.Columns[2].Visible = false; gItems.Columns[3].Visible = true; gItems.Columns[4].Visible = isRange; } gItems.Columns[5].Visible = !contentChannel.ContentChannelType.DisablePriority; lContentChannel.Text = contentChannel.Name; _typeId = contentChannel.ContentChannelTypeId; if ( !string.IsNullOrWhiteSpace( contentChannel.IconCssClass ) ) { cssIcon = contentChannel.IconCssClass; } } lIcon.Text = string.Format( "<i class='{0}'></i>", cssIcon ); // Block Security and special attributes (RockPage takes care of View) bool canAddEditDelete = IsUserAuthorized( Authorization.EDIT ); gfFilter.ApplyFilterClick += gfFilter_ApplyFilterClick; gfFilter.DisplayFilterValue += gfFilter_DisplayFilterValue; gItems.DataKeyNames = new string[] { "Id" }; gItems.Actions.ShowAdd = canAddEditDelete; gItems.IsDeleteEnabled = canAddEditDelete; gItems.Actions.AddClick += gItems_Add; gItems.GridRebind += gItems_GridRebind; AddAttributeColumns(); if ( contentChannel != null && contentChannel.RequiresApproval ) { var statusField = new BoundField(); gItems.Columns.Add( statusField ); statusField.DataField = "Status"; statusField.HeaderText = "Status"; statusField.SortExpression = "Status"; statusField.HtmlEncode = false; } var securityField = new SecurityField(); gItems.Columns.Add( securityField ); securityField.TitleField = "Title"; securityField.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.ContentChannelItem ) ).Id; var deleteField = new DeleteField(); gItems.Columns.Add( deleteField ); deleteField.Click += gItems_Delete; // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it this.BlockUpdated += Block_BlockUpdated; this.AddConfigurationUpdateTrigger( upnlContent ); } else { upnlContent.Visible = false; } }