Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Inherits from Control, Yay, Inherits from WebControl, Nay....

Thread Tools

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

Alex Nitulescu
Posts: n/a
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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
difference Inherits CompositeControl vs Inherits WebControl ton ASP .Net Building Controls 1 06-24-2007 07:49 AM
Bit lost (inherits/imports) for secure login... Rob Meade ASP .Net 0 01-28-2004 01:24 PM
Changing Default Inherits. Greg Richards ASP .Net 3 12-09-2003 01:02 PM
inheriting from a class that inherits from the UserControl class Joel Barsotti ASP .Net 4 10-30-2003 08:05 PM
Inherits from web user control ton ASP .Net 1 10-17-2003 12:17 PM