470,628 Members | 2,314 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,628 developers. It's quick & easy.

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

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

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)
End If
End Sub

Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)

If TypeOf obj Is RotatorItem1 Then
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
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
Return _color
End Get

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

Protected Overrides Sub Render(ByVal writer As

writer.AddAttribute("color", [Color])
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"
<raducu:RotatorItem1 id="Rotatoritem12" text="Two" color="green"
<raducu:RotatorItem1 id="Rotatoritem13" text="Three" color="blue"
<raducu:RotatorItem1 id="Rotatoritem14" text="Four"

However, I get

Type 'RaducuCustomControls.Rotator1' does not have a property named

on <raducu:RotatorItem1 id="RotatorItem11" text="One" color="red"

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.
Nov 19 '05 #1
0 1045

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Josema | last post: by
5 posts views Thread by Eric | last post: by
5 posts views Thread by serge calderara | last post: by
1 post views Thread by Jeremy Chapman | last post: by
5 posts views Thread by =?Utf-8?B?bXVzb3NkZXY=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.