?? bookpublisher.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.Books;
//*********************************************************************
//
// BookPublisher Class
//
// Represents a book publisher
//
//*********************************************************************
[Designer(typeof(ASPNET.StarterKit.Communities.CommunityDesigner))]
public class BookPublisher : WebControl {
private string _text = String.Empty;
private string _link = String.Empty;
//*********************************************************************
//
// BookPublisher Constructor
//
// Assign a default css style (the user can override)
//
//*********************************************************************
public BookPublisher() : base() {
CssClass = "bookPublisher";
// Get ContentInfo object
if (Context != null) {
BookInfo objBookInfo = (BookInfo)Context.Items["ContentInfo"];
_text = objBookInfo.Publisher;
_link = objBookInfo.PublisherLink;
}
}
//*********************************************************************
//
// TagKey Property
//
// Only display a link if publisherLink has value
//
//*********************************************************************
override protected HtmlTextWriterTag TagKey {
get {
if (_link == String.Empty)
return HtmlTextWriterTag.Span;
else
return HtmlTextWriterTag.A;
}
}
//*********************************************************************
//
// AddAttributesToRender Method
//
// Add the HRef that links to the publisher
//
//*********************************************************************
protected override void AddAttributesToRender(HtmlTextWriter writer) {
if (_link != String.Empty) {
writer.AddAttribute(HtmlTextWriterAttribute.Href, _link);
writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
base.AddAttributesToRender(writer);
}
}
//*********************************************************************
//
// RenderContents Method
//
// Display the title
// Note: we are going to HTML Encode here to prevent script injections
//
//*********************************************************************
override protected void RenderContents(HtmlTextWriter writer) {
writer.Write(HttpUtility.HtmlEncode(_text));
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -