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

📄 downloadlink.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.Downloads;




    //*********************************************************************
    //
    // DownloadLink Class
    //
    // Represents a link to a file
    //
    //*********************************************************************

	public class DownloadLink : WebControl {


        private string _text = String.Empty;
        private int _contentPageID;
    

        //*********************************************************************
        //
        // DownloadLink Constructor
        //
        // Set the default css class
        //
        //*********************************************************************
		public DownloadLink() : base(HtmlTextWriterTag.A) {
			CssClass = "downloadLink";

            // Get DownloadInfo object
			if (Context != null) {
				ContentInfo objContentInfo = (ContentInfo)Context.Items["ContentInfo"];
			    _contentPageID = objContentInfo.ContentPageID;
			}
		}
		



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



        //*********************************************************************
        //
        // AddAttributesToRender Method
        //
        // Add the HRef that links to the profile page
        //
        //*********************************************************************
        protected override void AddAttributesToRender(HtmlTextWriter writer) {
            string link = CommunityGlobals.CalculatePath(String.Format("Downloads_GetFile.aspx?id={0}", _contentPageID));
            writer.AddAttribute(HtmlTextWriterAttribute.Href, link);
            base.AddAttributesToRender(writer);
        }        


        //*********************************************************************
        //
        // RenderContents method
        //
        // Display the link label with author name
        // Notice that we HtmlEncode (Thanks Andrew D!)
        //
        //*********************************************************************
        override protected void RenderContents(HtmlTextWriter writer) {
            writer.Write(_text);    
        }


    }
}

⌨️ 快捷键说明

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