itemphotoviewdetails.cs

来自「完全网站系统」· CS 代码 · 共 119 行

CS
119
字号
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.PhotoGallery;



    //*********************************************************************
    //
    // ItemPhotoViewDetails Class
    //
    // Represents a link to a photo
    //
    //*********************************************************************

	public class ItemPhotoViewDetails : WebControl {

        private string _text = String.Empty;

    
        //*********************************************************************
        //
        // ItemPhotoViewDetails Constructor
        //
        // Assign a default css style (the user can override)
        //
        //*********************************************************************
		public ItemPhotoViewDetails() : base(HtmlTextWriterTag.A) {
			CssClass = "itemPhotoViewDetails";
    	    EnableViewState = false;
    	}



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


        //*********************************************************************
        //
        // ContentPageID Property
        //
        // Store content page ID in View State
        //
        //*********************************************************************
		public int ContentPageID {
		      get {
		          if (ViewState["ContentPageID"] == null)
		              return -1;
		          else
		              return (int)ViewState["ContentPageID"];
		      }
		      set { ViewState["ContentPageID" ] = value; }
    	}



    
        //*********************************************************************
        //
        // OnDataBinding Method
        //
        // Get the content page id from the container's DataItem property
        //
        //*********************************************************************
        override protected void OnDataBinding(EventArgs e) {
            ContentItem item;

            if (NamingContainer is ContentItem)
                item = (ContentItem)NamingContainer;
            else
                item = (ContentItem)NamingContainer.NamingContainer;

            ContentInfo objContentInfo = (ContentInfo)item.DataItem;
            ContentPageID = objContentInfo.ContentPageID;
        }

        


        protected override void AddAttributesToRender(HtmlTextWriter writer) {
            string link;
            
            link = String.Format("{0}.aspx", ContentPageID);
            
            writer.AddAttribute(HtmlTextWriterAttribute.Href, link);
            base.AddAttributesToRender(writer);
        }        
        

    
        //*********************************************************************
        //
        // RenderContents Method
        //
        // Display the link
        //
        //*********************************************************************
        override protected void RenderContents(HtmlTextWriter writer) {
            
            writer.Write(HttpUtility.HtmlEncode(_text));    
        }


    }
}

⌨️ 快捷键说明

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