Getting Started: Creating SimpleControl
We’re going to get started by creating a simple control that outputs a text string to the HTML stream. It has a single property with which the output string can be set, or the control can be used with the default string.
Take a look at the control’s source code in Listing 13.1, and then I’ll talk about it. This code would be found in your .cs source code file if you were adding a control to your project.
Listing 13.1. The Source Code for SimpleControl
[DefaultProperty(“Text”), ShowInToolbox(true), ToolboxData(“<{0}:SimpleControl runat=server></{0}:SimpleControl>”)] public class SimpleControl : System.Web.UI.WebControls.WebControl { private string m_strText; [Bindable(true), Category(“Appearance”), DefaultValue(“<h1>.NET ... |
Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.