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

📄 bookpurchaselink.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;



    //*********************************************************************
    //
    // BookPurchaseLink Class
    //
    // Represents a link to purchase the book
    //
    //*********************************************************************
	[Designer(typeof(ASPNET.StarterKit.Communities.CommunityDesigner))]
	public class BookPurchaseLink : WebControl {

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

            // Get ContentInfo object
			if (Context != null) {
				BookInfo objBookInfo = (BookInfo)Context.Items["ContentInfo"];
			    _link = objBookInfo.PurchaseLink;
			    Context.Trace.Warn(_link);
			}
		}

    
        //*********************************************************************
        //
        // Text Property
        //
        // The text displayed in the purchase link
        //
        //*********************************************************************
        public string Text {
            get { return _text; }
            set { _text = value; }
        }



        //*********************************************************************
        //
        // Render Method
        //
        // Only render when URL supplied
        //
        //*********************************************************************
        override protected void Render(HtmlTextWriter writer) {
            if (_link != String.Empty)
                base.Render(writer);
        }


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

        override protected HtmlTextWriterTag TagKey {
            get { 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 + -