📄 downloadlink.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 + -