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

📄 commentreply.cs

📁 ASP开发网站的 关于网站的设计和说明 还有SQL的程序 数据库
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
	using System.ComponentModel;


    //*********************************************************************
    //
    // CommentReply Class
    //
    // Represents a link to a page to add a comment.
    // This was originally implemented by overriding the HyperLink control.
    // Unfortunately, the HyperLink control does not resolve paths 
    // correctly when used in skins, so we have to do some extra work.
    // This control will also check comment permissions before displaying the link.
    //
    //*********************************************************************

	[Designer(typeof(ASPNET.StarterKit.Communities.CommunityDesigner))]
    public class CommentReply : WebControl {

        private string _text = String.Empty;
        private string _imageUrl = String.Empty;
        private string _replyUrl = "Comments_AddComment.aspx?id={0}";


        //*********************************************************************
        //
        // Text Property
        //
        // The text to display in the Hyperlink
        //
        //*********************************************************************
        public string Text {
            get {return _text;}
            set {_text = value;}
        }





        //*********************************************************************
        //
        // ImageUrl Property
        //
        // The path for the (optional) picture to display in the hyperlink.
        //
        //*********************************************************************
        public string ImageUrl {
            get {return _imageUrl;}
            set {_imageUrl = value;}
        }




        //*********************************************************************
        //
        // ReplyUrl Property
        //
        // The path for the comment page (defaults to the standard one).
        //
        //*********************************************************************
        public string ReplyUrl {
            get {return _replyUrl;}
            set {_replyUrl = value;}
        }


        //*********************************************************************
        //
        // AddAttributesToRender Method
        //
        // Add the HRef that links to the AddContent page
        //
        //*********************************************************************
        protected override void AddAttributesToRender(HtmlTextWriter writer) {
            ContentInfo objContentInfo  = (ContentInfo)Context.Items["ContentInfo"];
            string replyLink = String.Format(_replyUrl, objContentInfo.ContentPageID);
            writer.AddAttribute(HtmlTextWriterAttribute.Href, CommunityGlobals.CalculatePath(replyLink));
            base.AddAttributesToRender(writer);
        }        

        

        //*********************************************************************
        //
        // Render Method
        //
        // Here's where we check add permissions
        //
        //*********************************************************************
        override protected void Render(HtmlTextWriter writer) {
            UserInfo objUserInfo = (UserInfo)Context.Items["UserInfo"];
            SectionInfo objSectionInfo = (SectionInfo)Context.Items["SectionInfo"];
            if (objUserInfo.MayComment||Array.IndexOf(objSectionInfo.CommentRoles, "Community-Authenticated" )!=-1)
                base.Render(writer);
        }


        //*********************************************************************
        //
        // RenderContents Method
        //
        // Display the contents of the link
        //
        //*********************************************************************
        override protected void RenderContents(HtmlTextWriter writer) {
            if (_imageUrl == String.Empty) 
                writer.Write(_text);
            else 
                writer.Write(String.Format("<img src=\"{0}\" alt=\"{1}\" border=\"0\" />", Page.ResolveUrl(_imageUrl), _text));
        }



        //*********************************************************************
        //
        // TagKey Property
        //
        // We want to create an A tag around the content of this control
        //
        //*********************************************************************
        override protected HtmlTextWriterTag TagKey {
            get { return HtmlTextWriterTag.A; }
        }
        


    }
}

⌨️ 快捷键说明

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