Adding a Web Control Library to a Web page : Extends WebControl « Custom Controls « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » Custom Controls » Extends WebControl 
14.23.3.Adding a Web Control Library to a Web page
<%@ Register Assembly="ClassLibrary1" Namespace="ClassLibrary1" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Adding a Custom Web Control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <cc1:WebCustomControl1 ID="WebCustomControl1_1" runat="server" />
    </div>
    </form>
</body>
</html>

File: WebCustomControl1_1.cs

Imports System.ComponentModel
Imports System.Web.UI

<DefaultProperty("Text"), _
 ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")
Public Class WebCustomControl1
    Inherits System.Web.UI.WebControls.WebControl

    Dim _text As String

    <Bindable(True), Category("Appearance"), DefaultValue("")> _
    Property [Text]() As String
        Get
            Return _text
        End Get

        Set(ByVal Value As String)
            _text = Value
        End Set
    End Property

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
        output.Write([Text])
    End Sub

End Class
14.23.Extends WebControl
14.23.1.The Visual Studio Web Control Library class template (C#)
14.23.2.The Visual Studio Web Control Library class template (VB)
14.23.3.Adding a Web Control Library to a Web page
14.23.4.Using the HtmlTextWriter to render an HTML tag (C#)
14.23.5.Using the HtmlTextWriter to render an HTML tag (VB)
14.23.6.Using the HtmlTextWriter to render multiple HTML tags (C#)
14.23.7.Using the HtmlTextWriter to render multiple HTML tags (VB)
14.23.8.Rendering HTML tag attributes (C#)
14.23.9.Rendering HTML tag attributes (VB)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.