Adding and populating a custom property for a user control

Discussion in 'ASP .Net Web Controls' started by Mike Owen, Jul 20, 2007.

  1. Mike Owen

    Mike Owen Guest

    I have built and used a custom control which works fine.

    I now want to add a property that I can set from the various pages where I
    use the control.

    I have added the following property in the code behind file:

    Public Property ContentTypeID() As Int16
    Get

    Return mContentTypeID

    End Get
    Set(ByVal value As Int16)

    mContentTypeID = value

    End Set
    End Property

    and set it in the page as follows:

    <%@ Register TagPrefix="uc1" TagName="_Content" Src="~/_Content.ascx" %>
    <uc1:_Content id=_Content ContentTypeID=10 runat="server"></uc1:_Content>

    However in design time the error 'Attribute ContentTypeID is not a valid
    attribute of element _Content' comes up for the property/attribute
    ContentTypeID, and of course the value of 10 is not passed through to the
    code behind file.

    Any ideas what I am doing wrong?


    Thanks, Mike.
     
    Mike Owen, Jul 20, 2007
    #1
    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. Ozan Kozan via .NET 247

    Help!!Adding Property(XmlDocument ) to your custom control !!

    Ozan Kozan via .NET 247, Aug 4, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    416
    Ozan Kozan via .NET 247
    Aug 4, 2004
  2. AleXmanFree
    Replies:
    3
    Views:
    595
    Hillbilly
    Oct 9, 2008
  3. Rob Joosen

    Keep custom property-value in custom rendered control

    Rob Joosen, May 12, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    157
    Rob Joosen
    May 12, 2004
  4. Travis Pruitt

    Dynamically Adding User Control with Child User Control

    Travis Pruitt, Jan 13, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    200
    Travis Pruitt
    Jan 13, 2005
  5. Mike Owen

    Adding and populating a custom property for a user control

    Mike Owen, Jul 20, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    236
    Mike Owen
    Jul 22, 2007
Loading...

Share This Page