Summary description for Comments.
상속: BaseControl, IEntryControl
        public void AddControlToBody_WithPostComment_AddsControlToUpdatePanelAndUpdatePanelToCenterBodyControl()
        {
            // arrange
            var updatePanel = new UpdatePanel();
            var postCommentControl = new PostComment();
            var bodyControl = new UserControl();
            var page = new SubtextMasterPage();

            // act
            page.AddControlToBody("PostComment", postCommentControl, updatePanel, bodyControl);

            // assert
            Assert.AreEqual(postCommentControl, updatePanel.ContentTemplateContainer.Controls[0]);
            Assert.AreEqual(updatePanel, bodyControl.Controls[0]);
            Assert.IsTrue(postCommentControl.Visible);
        }
예제 #2
0
        private void InitializeBlogPage()
        {
            MaintainScrollPositionOnPostBack = true;
            CurrentBlog = Config.CurrentBlog;

            string skinFolder = CurrentSkin.TemplateFolder;

            string[] controls = HandlerConfiguration.GetControls(Context);
            if (controls != null)
            {
                UpdatePanel apnlCommentsWrapper = new UpdatePanel();
                apnlCommentsWrapper.Visible = true;
                apnlCommentsWrapper.ID = CommentsPanelId;

                foreach (string controlId in controls)
                {
                    Control control = LoadControl(string.Format(ControlLocation, skinFolder, controlId));
                    control.ID = controlId.Replace(".", "_");

                    if (controlId.Equals("Comments.ascx"))
                    {
                        control.Visible = true;
                        commentsControl = control as Comments;
                        apnlCommentsWrapper.ContentTemplateContainer.Controls.Add(control);
                    }
                    else if (controlId.Equals("PostComment.ascx"))
                    {
                        postCommentControl = (PostComment)control;
                        postCommentControl.CommentApproved += postCommentControl_CommentPosted;
                        apnlCommentsWrapper.ContentTemplateContainer.Controls.Add(control);
                        CenterBodyControl.Controls.Add(apnlCommentsWrapper);
                    }
                    else
                    {
                        CenterBodyControl.Controls.Add(control);
                    }
                }
            }

            if (CurrentSkin.HasCustomCssText)
            {
                CustomCss.Attributes.Add("href", CurrentBlog.RootUrl + "customcss.aspx");
            }
            else
            {
                //MAC IE does not like the empy CSS file, plus its a waste :)
                CustomCss.Visible = false;
            }

            if (Rsd != null)
            {
                Rsd.Attributes.Add("href", CurrentBlog.RootUrl + "rsd.xml.ashx");
            }

            if (RSSLink != null)
            {
                RSSLink.Attributes.Add("href", CurrentBlog.UrlFormats.RssUrl.ToString());
            }

            if (AtomLink != null)
            {
                AtomLink.Attributes.Add("href", CurrentBlog.UrlFormats.RssUrl.ToString());
            }

            // if specified, add script elements
            if (scripts != null)
            {
                scripts.Text = scriptRenderer.RenderScriptElementCollection(CurrentSkin.SkinKey);
            }

            if (styles != null)
            {
                styles.Text = styleRenderer.RenderStyleElementCollection(CurrentSkin.SkinKey);
            }

            if (openIDServer != null && !string.IsNullOrEmpty(CurrentBlog.OpenIDServer))
            {
                openIDServer.Text = string.Format(OpenIDServerLocation, CurrentBlog.OpenIDServer);
            }

            if (openIDDelegate != null && !string.IsNullOrEmpty(CurrentBlog.OpenIDDelegate))
            {
                openIDDelegate.Text = string.Format(OpenIDDelegateLocation, CurrentBlog.OpenIDDelegate);
            }

            // Add the per-blog MetaTags to the page Head section.
            IPagedCollection<MetaTag> blogMetaTags = MetaTags.GetMetaTagsForBlog(CurrentBlog, 0, int.MaxValue);
            foreach (MetaTag tag in blogMetaTags)
            {
                HtmlMeta mt = new HtmlMeta();
                mt.Content = tag.Content;

                if (!string.IsNullOrEmpty(tag.Name))
                    mt.Name = tag.Name;
                else
                    mt.HttpEquiv = tag.HttpEquiv;

                Literal newLineLiteral = new Literal();
                newLineLiteral.Text = Environment.NewLine;
                metaTagsPlaceHolder.Controls.Add(newLineLiteral);
                metaTagsPlaceHolder.Controls.Add(mt);
            }
        }