Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

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


 
Reply With Quote
 
 
 
Reply

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



Advertisments