⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userlist.cs

📁 微软的.NET论坛的源代码(COOL!!!)
💻 CS
📖 第 1 页 / 共 2 页
字号:
        //  HandleDataBindingForUserCount
        //
        /// <summary>
        /// Handles the databinding for the user count
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDataBindingForUserCount(Object sender, EventArgs e) {	
            Label count = (Label) sender;
            DataListItem container = (DataListItem) count.NamingContainer;

            if (UserCountIsAscending)
                count.Text = (UserCount++).ToString("n0");
            else
                count.Text = (UserCount--).ToString("n0");
        }

        // *********************************************************************
        //  HandleDatabindingForUsername
        //
        /// <summary>
        /// Handles the databinding for the user count
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDatabindingForUsername(Object sender, EventArgs e) {	
            HyperLink username = (HyperLink) sender;
            DataListItem container = (DataListItem) username.NamingContainer;

            User userToDisplay = (User) container.DataItem;

            username.Text = userToDisplay.Username;
            username.NavigateUrl = Globals.UrlUserProfile + userToDisplay.Username;
        }

        // *********************************************************************
        //  HandleDatabindingForDateJoined
        //
        /// <summary>
        /// Handles the databinding for the date the user joined
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDatabindingForDateJoined(Object sender, EventArgs e) {	
            Label dateJoined = (Label) sender;
            DataListItem container = (DataListItem) dateJoined.NamingContainer;
            string dateFormat;

            if (ForumUser != null)
                dateFormat = ForumUser.DateFormat;
            else
                dateFormat = Globals.DateFormat;

            User userToDisplay = (User) container.DataItem;

            dateJoined.Text = userToDisplay.DateCreated.ToString(dateFormat);
        }
        
        // *********************************************************************
        //  HandleDatabindingForWebsite
        //
        /// <summary>
        /// Handles the databinding for the user's website
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDatabindingForWebsite(Object sender, EventArgs e) {	
            HyperLink website = (HyperLink) sender;
            DataListItem container = (DataListItem) website.NamingContainer;
            Uri url;

            User userToDisplay = (User) container.DataItem;

            // Only display the web site if we have it.
            if (userToDisplay.Url.Length > 6) {
                url = new Uri(userToDisplay.Url);
                website.Text = "http://" + url.Host.ToString(); //userToDisplay.Url;
                website.NavigateUrl = userToDisplay.Url;
            } else {
                website.Text = "-";
            }

        }

        // *********************************************************************
        //  HandleDatabindingForLocation
        //
        /// <summary>
        /// Handles the databinding for the user's location
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDatabindingForLocation(Object sender, EventArgs e) {	
            Label location = (Label) sender;
            DataListItem container = (DataListItem) location.NamingContainer;

            User userToDisplay = (User) container.DataItem;

            location.Text = userToDisplay.Location;

        }

        // *********************************************************************
        //  HandleDatabindingForLastActivtyDate
        //
        /// <summary>
        /// Handles the databinding for the user's location
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDatabindingForLastActivtyDate(Object sender, EventArgs e) {	
            Label lastActive = (Label) sender;
            DataListItem container = (DataListItem) lastActive.NamingContainer;
            string dateFormat;

            if (ForumUser != null)
                dateFormat = ForumUser.DateFormat;
            else
                dateFormat = Globals.DateFormat;

            User userToDisplay = (User) container.DataItem;

            lastActive.Text = userToDisplay.LastActivity.ToString(dateFormat);

        }

        // *********************************************************************
        //  HandleDatabindingForTotalPosts
        //
        /// <summary>
        /// Handles the databinding for the user's total posts
        /// </summary>
        /// 
        // ********************************************************************/
        private void HandleDatabindingForTotalPosts(Object sender, EventArgs e) {	
            HyperLink totalPosts = (HyperLink) sender;
            DataListItem container = (DataListItem) totalPosts.NamingContainer;

            User userToDisplay = (User) container.DataItem;

            if (userToDisplay.TotalPosts > 0) {
                totalPosts.Text = userToDisplay.TotalPosts.ToString("n0");
                totalPosts.NavigateUrl = Globals.UrlSearchForPostsByUser + userToDisplay.Username;
            } else {
                totalPosts.Text = "-";
            }

        }

        
        // *********************************************************************
        //  BuildHeaderTemplate
        //
        /// <summary>
        /// This function is called to create the template for the header
        /// </summary>
        /// 
        // ********************************************************************/
        override protected void BuildHeaderTemplate(Control _ctrl) {

            System.Web.UI.IParserAccessor __parser = ((System.Web.UI.IParserAccessor)(_ctrl));

            __parser.AddParsedSubObject(RenderHeaderTemplate());
            
        }

        // *********************************************************************
        //  BuildItemTemplate
        //
        /// <summary>
        /// This function is called to create the template for the header
        /// </summary>
        /// 
        // ********************************************************************/
        override protected void BuildItemTemplate(Control _ctrl) {

            System.Web.UI.IParserAccessor __parser = ((System.Web.UI.IParserAccessor)(_ctrl));

            __parser.AddParsedSubObject(RenderItemTemplate());

        }

        // *********************************************************************
        //  BuildFooterTemplate
        //
        /// <summary>
        /// This function is called to create the template for the footer
        /// </summary>
        /// 
        // ********************************************************************/
        override protected void BuildFooterTemplate(Control _ctrl) {

            System.Web.UI.IParserAccessor __parser = ((System.Web.UI.IParserAccessor)(_ctrl));

            __parser.AddParsedSubObject(RenderFooterTemplate());
            
        }

        // *********************************************************************
        //  UserCount
        //
        /// <summary>
        /// Sets/Gets the total number of users
        /// </summary>
        /// 
        // ********************************************************************/
        public int UserCount {
            get {return userCount; }
            set {userCount = value; }
        }

        // *********************************************************************
        //  UserCountIsAscending
        //
        /// <summary>
        /// Controls direction of user counting
        /// </summary>
        /// 
        // ********************************************************************/
        public bool UserCountIsAscending {
            get {return userCountIsAscending; }
            set {userCountIsAscending = value; }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -