downloadattachmentlink.cs

来自「community server 源码」· CS 代码 · 共 65 行

CS
65
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CommunityServer.Controls;

namespace CommunityServer.Blogs.Controls
{
	/// <summary>
	/// Summary description for AboutView.
	/// </summary>
	public class DownloadAttachmentLink : WeblogThemedControl
	{
		public DownloadAttachmentLink()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        protected HyperLink downloadLink;
        private PostAttachmentMetaData _data = null;


        protected override void AttachChildControls()
        {
            downloadLink = FindControl("DownLoadLink") as HyperLink;
        }
        
        public PostAttachmentMetaData DataSource
        {
            get{return _data;}
            set{_data = value;}
        }

        public override void DataBind()
        {
            base.DataBind ();

            if(DataSource != null && downloadLink != null)
            {
                downloadLink.NavigateUrl = BlogUrls.Instance().AttachmentUrl(this.CurrentWeblog,  DataSource);
                downloadLink.Text = DataSource.FileName;
                if(DataSource.IsRemote)
                    downloadLink.Target = "_blank";
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender (e);
            if(DataSource == null || downloadLink == null)
                this.Visible = false;
        }


	}
}

⌨️ 快捷键说明

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