예제 #1
0
        private void RenderPostsMenu()
        {
            ThreadCollection posts    = Threads.GetAllThreads(Post.ForumID, 20, 0, DateTime.MinValue, Context.User.Identity.Name, false);
            string           postMenu = "<div class='popupMenu' style='position: absolute; display: none;' id='" + this.UniqueID + ":postMenu'>";

            postMenu += "<div class='popupTitle'>Posts</div>";
            for (int i = 0; i < posts.Count && i < 20; i++)
            {
                postMenu += "<div class='popupItem'> <a href='" + UrlShowPost + ((Post)posts[i]).PostID +
                            "'>" + ((Post)posts[i]).Subject + "</a> </div>";
            }
            postMenu += "</div>";
            Page.RegisterClientScriptBlock(this.UniqueID + ":postMenu", postMenu);
        }
        // *********************************************************************
        //  OnPreRender
        //
        /// <summary>
        /// Override OnPreRender and databind
        /// </summary>
        ///
        // ********************************************************************/
        protected override void OnPreRender(EventArgs e)
        {
            ThreadCollection threads;
            string           username = null;

            if (null != ForumUser)
            {
                username = ForumUser.Username;
            }

            // Get the total records in the pager
            if (hideReadThreads != null)
            {
                pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter(), username, hideReadThreads.Checked);
            }
            else
            {
                pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter(), username, false);
            }

            // User specific data source
            if ((ForumUser != null) && (hideReadThreads != null))
            {
                threads = Threads.GetAllThreads(ForumID, pager.PageSize, pager.PageIndex, CalculateDateTimeFilter(), username, hideReadThreads.Checked);
            }
            else
            {
                threads = Threads.GetAllThreads(ForumID, pager.PageSize, pager.PageIndex, CalculateDateTimeFilter(), null, false);
            }

            // Do we have data to display?
            if ((threads.Count == 0) && (forum.TotalThreads > 0))
            {
                noPostsDueToFilter.Visible = true;
            }
            else if (threads.Count == 0)
            {
                noThreads.Visible          = true;
                noPostsDueToFilter.Visible = false;
            }
            else
            {
                noThreads.Visible          = false;
                noPostsDueToFilter.Visible = false;
                markAllRead.Visible        = true;
                threadList.DataSource      = threads;
                threadList.DataBind();
            }
        }