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

📄 bookpublisher.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
	using ASPNET.StarterKit.Communities.Books;



    //*********************************************************************
    //
    // BookPublisher Class
    //
    // Represents a book publisher
    //
    //*********************************************************************
	[Designer(typeof(ASPNET.StarterKit.Communities.CommunityDesigner))]
	public class BookPublisher : WebControl {

        private string _text = String.Empty;
        private string _link = String.Empty;
        
    
        //*********************************************************************
        //
        // BookPublisher Constructor
        //
        // Assign a default css style (the user can override)
        //
        //*********************************************************************
        public BookPublisher() : base() {
            CssClass = "bookPublisher";

            // Get ContentInfo object
			if (Context != null) {
				BookInfo objBookInfo = (BookInfo)Context.Items["ContentInfo"];
			    _text = objBookInfo.Publisher;
			    _link = objBookInfo.PublisherLink;
			}
		}

    

        //*********************************************************************
        //
        // TagKey Property
        //
        // Only display a link if publisherLink has value
        //
        //*********************************************************************

        override protected HtmlTextWriterTag TagKey {
            get {
                if (_link == String.Empty)
                    return HtmlTextWriterTag.Span;
                else
                    return HtmlTextWriterTag.A;
            }
        }


        //*********************************************************************
        //
        // AddAttributesToRender Method
        //
        // Add the HRef that links to the publisher
        //
        //*********************************************************************
        protected override void AddAttributesToRender(HtmlTextWriter writer) {
            if (_link != String.Empty) {
                writer.AddAttribute(HtmlTextWriterAttribute.Href, _link);
                writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
                base.AddAttributesToRender(writer);
            }
        }        


    
        //*********************************************************************
        //
        // RenderContents Method
        //
        // Display the title
        // Note: we are going to HTML Encode here to prevent script injections
        //
        //*********************************************************************
        override protected void RenderContents(HtmlTextWriter writer) {
			writer.Write(HttpUtility.HtmlEncode(_text));    
        }


    }
}

⌨️ 快捷键说明

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