ASP.NET Tutorial/Custom Controls/Panel

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Creating the templated control"s inner control class (C#)

using System;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebControlLibrary1
{
    public class Message : Panel, INamingContainer
    {
        private string _name;
        private string _text;
        public Message(string name, string text)
        {
            _text = text;
            _name = name;
        }
        public string Name
        {
            get { return _name; }
        }
        public string Text
        {
            get { return _text; }
        }
    }
}


Creating the templated control"s inner control class (VB)

Public Class Message
    Inherits System.Web.UI.WebControls.Panel
    Implements System.Web.UI.INamingContainer
    Private _name As String
    Private _text As String
    Public Sub New(ByVal name As String, ByVal text As String)
        _text = text
        _name = name
    End Sub
    Public ReadOnly Property Name() As String
        Get
            Return _name
        End Get
    End Property
    Public ReadOnly Property Text() As String
        Get
            Return _text
        End Get
    End Property
End Class