📄 itemphotoviewdetails.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.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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -