当前位置: 首页>>代码示例>>C#>>正文


C# WebControl.RemoveCssClass方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.WebControl.RemoveCssClass方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.RemoveCssClass方法的具体用法?C# WebControl.RemoveCssClass怎么用?C# WebControl.RemoveCssClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.WebControl的用法示例。


在下文中一共展示了WebControl.RemoveCssClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetFollowing

        /// <summary>
        /// Configures a control to display and toggle following for the specified entity
        /// </summary>
        /// <param name="followEntity">The follow entity. NOTE: Make sure to use PersonAlias instead of Person when following a Person</param>
        /// <param name="followControl">The follow control.</param>
        /// <param name="follower">The follower.</param>
        public static void SetFollowing( IEntity followEntity, WebControl followControl, Person follower )
        {
            var followingEntityType = EntityTypeCache.Read( followEntity.GetType() );
            if ( follower != null && follower.PrimaryAliasId.HasValue )
            {
                using ( var rockContext = new RockContext() )
                {
                    var personAliasService = new PersonAliasService( rockContext );
                    var followingService = new FollowingService( rockContext );

                    var followingQry = followingService.Queryable()
                        .Where( f =>
                            f.EntityTypeId == followingEntityType.Id &&
                            f.PersonAlias.PersonId == follower.Id );

                    followingQry = followingQry.Where( f => f.EntityId == followEntity.Id );

                    if ( followingQry.Any() )
                    {
                        followControl.AddCssClass( "following" );
                    }
                    else
                    {
                        followControl.RemoveCssClass( "following" );
                    }
                }

                int entityId = followEntity.Id;

                // only show the following control if the entity has been saved to the database
                followControl.Visible = entityId > 0;

                string script = string.Format(
                    @"Rock.controls.followingsToggler.initialize($('#{0}'), {1}, {2}, {3}, {4});",
                        followControl.ClientID,
                        followingEntityType.Id,
                        entityId,
                        follower.Id,
                        follower.PrimaryAliasId );

                ScriptManager.RegisterStartupScript( followControl, followControl.GetType(), "following", script, true );
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:49,代码来源:FollowingsHelper.cs


注:本文中的System.Web.UI.WebControls.WebControl.RemoveCssClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。