
144
|
Chapter 6: User Controls and Custom Server Controls
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example 6-11 shows the code for the Blog control, updated with attributes to
enable design-time support for the control in Design view and the Property
browser. Note that the example adds several
using directives to import the
namespaces needed to support the attributes and designer classes we’ve used. The
example also adds an enumeration to be used for the value of the Mode property
and a new property, SeparatorColor.
Example 6-11. Updated Blog.cs
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
[
assembly: TagPrefix("aspnetian", "aspnetian")
]
namespace aspnetian
{
public enum BlogMode
{
Add,
Display
}
[
Description(@"Simple Blog control. Supports display of Web log / news
items from an XML file."),
Designer(typeof(aspnetian.BlogDesigner)),
ToolboxData("<{0}:Blog runat=server></{0}:Blog>")
]
public class Blog:Panel, INamingContainer
{
protected DataSet BlogDS;
protected TextBox TitleTB;
protected TextBox BlogText;
private string _addRedirect;
private string _email;
private BlogMode _mode;
private Color _separatorColor = Color.Black; ...