custom control - doesn't show

  • Thread starter Thread starter tepesco
  • Start date Start date
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
 
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.
 
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
 
Back
Top