custom control - doesn't show

T

tepesco

Hi..

I'm trying to create small custom control.. class definition in vb looks
like:

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Resources
Imports System.ComponentMode
Imports Anthem

Namespace WebContr.WebControls

Public Class DynamicList
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer


Protected Overloads Sub CreateChildControls()
Me.Controls.Clear()
Me.InitializeComponent()
End Sub

''' <summary>
''' Initializes the contained controls
''' </summary>
Private Sub InitializeComponent()

listBox = New Anthem.ListBox()
btUp = New Anthem.Button
btDown = New Anthem.Button

Me.btDown.Text = "Down"
Me.btUp.Text = "Up"

listBox.Visible = True
btUp.Visible = True
btDown.Visible = True

Me.Controls.Add(listBox)
Me.Controls.Add(btUp)
Me.Controls.Add(btDown)

End Sub

Protected Overloads Sub Render(ByVal render As HtmlTextWriter)
Me.EnsureChildControls()
Me.Render(render)
End Sub


Private listBox As Anthem.ListBox
Private btUp As Anthem.Button
Private btDown As Anthem.Button

End Class

End Namespace


And using it in aspx :

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<%@ Register TagPrefix="webCtrl" Namespace="WebContr.WebControls"
Assembly="WebContr.WebControls" %>

<html>
<head>
</head>
<body>
<webCtrl:DynamicList runat="server" Width="300" Height="300"
ID="dynList" Visible="true"></webCtrl:DynamicList>
</body>
</html>


But site is blank, what i'm doing wrong? thanks for answers

Regards
 
R

Registered User

Hi..

I'm trying to create small custom control.. class definition in vb looks
like:

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Resources
Imports System.ComponentMode
Imports Anthem

Namespace WebContr.WebControls

Public Class DynamicList
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer

Protected Overloads Sub CreateChildControls()
Me.Controls.Clear()
Me.InitializeComponent()
End Sub

''' <summary>
''' Initializes the contained controls
''' </summary>
Private Sub InitializeComponent()

listBox = New Anthem.ListBox()
btUp = New Anthem.Button
btDown = New Anthem.Button

Me.btDown.Text = "Down"
Me.btUp.Text = "Up"

listBox.Visible = True
btUp.Visible = True
btDown.Visible = True

Me.Controls.Add(listBox)
Me.Controls.Add(btUp)
Me.Controls.Add(btDown)

End Sub

Protected Overloads Sub Render(ByVal render As HtmlTextWriter)
Me.EnsureChildControls()
Me.Render(render)
End Sub

Private listBox As Anthem.ListBox
Private btUp As Anthem.Button
Private btDown As Anthem.Button

End Class

End Namespace


And using it in aspx :
-snip-

But site is blank, what i'm doing wrong? thanks for answers
Might I suggest deriving your contol from the CompositeControl type, I
believe it is more suitable for your needs. This link
http://msdn2.microsoft.com/en-us/library/3257x3ea.aspx
provides a very good example.

The answer to your question is the DynamicList type never gets
rendered. Excluding the call to EnsureChildControls the type's Render
method seems to do nothing but call itself. Review the Render
implementation on the linked page

regards
A.G.
 
T

tepesco

Hi
Might I suggest deriving your contol from the CompositeControl type, I
believe it is more suitable for your needs. This link
http://msdn2.microsoft.com/en-us/library/3257x3ea.aspx
provides a very good example.

The answer to your question is the DynamicList type never gets
rendered. Excluding the call to EnsureChildControls the type's Render
method seems to do nothing but call itself. Review the Render
implementation on the linked page

regards
A.G.

Thanks! Now works... Really big thanks

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top