Inherits from Control, Yay, Inherits from WebControl, Nay....

Discussion in 'ASP .Net' started by Alex Nitulescu, Feb 22, 2005.

  1. Hi, I have the following in project "RaducuCustomControls":

    Imports System.ComponentModel
    Imports System.Web.UI

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

    Public Items As New ArrayList()

    Protected Overrides Sub Render(ByVal output As
    System.Web.UI.HtmlTextWriter)

    Dim objRandom As New Random()
    Dim intRanIndex As Integer
    Dim objSelectedItem As RotatorItem1

    If Items.Count > 0 Then
    intRanIndex = objRandom.Next(Items.Count)
    objSelectedItem = CType(Items(intRanIndex), RotatorItem1)
    output.Write(objSelectedItem.Text)
    End If
    End Sub

    Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)

    If TypeOf obj Is RotatorItem1 Then
    Items.Add(obj)
    End If
    End Sub
    End Class

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

    Dim _text As String
    Dim _color As String

    <Description("The text of this item"), 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

    <Description("The color in which the text will be rendered"),
    Bindable(True), Category("Appearance"), DefaultValue("Black")> Property
    [Color]() As String
    Get
    Return _color
    End Get

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

    Protected Overrides Sub Render(ByVal writer As
    System.Web.UI.HtmlTextWriter)

    writer.AddAttribute("color", [Color])
    writer.RenderBeginTag("font")
    writer.Write([Text])
    writer.RenderEndTag()
    End Sub
    End Class

    I also have <Assembly: TagPrefix("RaducuCustomControls", "raducu")> in
    AssemblyInfo.vb in "RaducuCustomControls". Therefore, I expect the following
    code to run just fine:

    <raducu:Rotator1 id="Rotator11" runat="server">
    <raducu:RotatorItem1 id="RotatorItem11" text="One" color="red"
    runat="server"></raducu:RotatorItem1>
    <raducu:RotatorItem1 id="Rotatoritem12" text="Two" color="green"
    runat="server"></raducu:RotatorItem1>
    <raducu:RotatorItem1 id="Rotatoritem13" text="Three" color="blue"
    runat="server"></raducu:RotatorItem1>
    <raducu:RotatorItem1 id="Rotatoritem14" text="Four"
    runat="server"></raducu:RotatorItem1>
    </raducu:Rotator1>

    However, I get

    Type 'RaducuCustomControls.Rotator1' does not have a property named
    'raducu:RotatorItem1'.

    on <raducu:RotatorItem1 id="RotatorItem11" text="One" color="red"
    runat="server"></raducu:RotatorItem1>.

    If I change the Inherits in my custom control from Webcontrol to control, it
    works, although I don't see the properties I'm interested in.

    Please tell me, what am I missing here ?

    Thank you, Alex.
     
    Alex Nitulescu, Feb 22, 2005
    #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. Robert Oschler

    Got Python web host, yay! Now what?

    Robert Oschler, Aug 21, 2003, in forum: Python
    Replies:
    2
    Views:
    388
    Tyler Eaves
    Aug 22, 2003
  2. ton
    Replies:
    1
    Views:
    1,070
    Teemu Keiski
    Jun 24, 2007
  3. D.G.
    Replies:
    0
    Views:
    164
  4. ruby on rails! yay!

    , Oct 21, 2005, in forum: Ruby
    Replies:
    3
    Views:
    92
    Eric Hodel
    Oct 26, 2005
  5. Phillip Gawlowski

    HTML entites in ClothRed: yay or nay?

    Phillip Gawlowski, Apr 12, 2007, in forum: Ruby
    Replies:
    2
    Views:
    146
    John Joyce
    Apr 12, 2007
Loading...

Share This Page