Custom Control and properties window

Discussion in 'ASP .Net Web Controls' started by Leo, Oct 26, 2004.

  1. Leo

    Leo Guest

    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
     
    Leo, Oct 26, 2004
    #1
    1. Advertising

  2. Leo

    WALDO Guest

    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.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    WALDO, Oct 26, 2004
    #2
    1. Advertising

  3. Leo

    Leo Guest

    Correction, I meant User Control
     
    Leo, Oct 26, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski
    Replies:
    0
    Views:
    943
    Nathan Sokalski
    Oct 17, 2005
  2. Max2006
    Replies:
    2
    Views:
    530
    Max2006
    Jul 13, 2007
  3. daokfella
    Replies:
    0
    Views:
    466
    daokfella
    Jun 5, 2008
  4. Nathan Sokalski
    Replies:
    0
    Views:
    222
    Nathan Sokalski
    Oct 17, 2005
  5. Nathan Sokalski
    Replies:
    0
    Views:
    244
    Nathan Sokalski
    Oct 17, 2005
Loading...

Share This Page