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

📄 itemhasread.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 System.Diagnostics;



    //*********************************************************************
    //
    // ItemHasRead Class
    //
    // Displays different images depending on whether the content item
    // has already been viewed by the user.
    //
    //*********************************************************************

	public class ItemHasRead : WebControl {
	
	   string _readImage = "~/Communities/Common/Images/HasRead/Read.Gif";
	   string _notReadImage = "~/Communities/Common/Images/HasRead/NotRead.Gif";
	
	
	    public string ReadImage {
	       get {return _readImage; }
	       set {_readImage = value; }
	    
	    }


	
	    public string NotReadImage {
	       get {return _notReadImage; }
	       set {_notReadImage = value; }
	    
	    }


    
        //*********************************************************************
        //
        // ItemHasRead Constructor
        //
        // Assign a default css style (the user can override)
        //
        //*********************************************************************
		public ItemHasRead() {
			CssClass = "hasRead";
            EnableViewState = false;
		}

    
        //*********************************************************************
        //
        // OnDataBinding Method
        //
        // Get the read status 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;
            ViewState["HasRead"] = objContentInfo.HasRead;
        }


    
        //*********************************************************************
        //
        // RenderContents Method
        //
        // Display the HasRead image
        //
        //*********************************************************************
        override protected void RenderContents(HtmlTextWriter writer) {
            if ((bool)ViewState["HasRead"])
                writer.Write(String.Format("<img src=\"{0}\">", Page.ResolveUrl(_readImage))); 
            else
                writer.Write(String.Format("<img src=\"{0}\">", Page.ResolveUrl(_notReadImage))); 
        }




    }
}

⌨️ 快捷键说明

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