Custom Control and properties window

L

Leo

I am building a custom control, code at bottom, and after I place it on a
web page I would like to see the Title property in the properties window
when the control is selected at design time. How do I accomplish this?


Imports System.ComponentModel

<Description("Top of Web page"), Browsable(True), DefaultValue("Title")> _
Public Class Header
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
Protected WithEvents hypHome As System.Web.UI.WebControls.HyperLink
Protected WithEvents lblPath As System.Web.UI.WebControls.Label
Protected WithEvents lblUser As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

<Browsable(True), DefaultValue("Title"), Description("The title of the
page"), Category("Appearance")> _
Public Property Title() As String
Get
Return lblTitle.Text
End Get
Set(ByVal Value As String)
lblTitle.Text = Value
End Set
End Property

<Browsable(True), DefaultValue(""), Description("The logged on name")> _
Public WriteOnly Property User() As String
Set(ByVal Value As String)
lblUser.Text = Value
End Set
End Property

<Browsable(True), DefaultValue(""), Description("The path in the website
of the page")> _
Public WriteOnly Property Path() As String
Set(ByVal Value As String)
lblPath.Text = Value
End Set
End Property

<Browsable(True), DefaultValue(""), Description("A hyperlink to the
page")> _
Public WriteOnly Property Home() As String
Set(ByVal Value As String)
hypHome.Text = Value
End Set
End Property
End Class
 
W

WALDO

Inherit from System.Web.UI.Control or
System.Web.UI.WebControls.WebControl, rather than UserControl.

If you inherit from WebControl, you'll get a bunch of properties you may
or may not need like BackColor, but you can ignore those. Also if you
inherit from WebControl, you'll get sizing handles as opposed to
Control, where you won't.

Inheriting from either of these will also get you some visual
design-time support, rather than that ugly gray box.

The simplest answer is to inherit from WebControl.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top