OnPreRender for Button Array Control

C

Chad Stoker

I have an array of Button Controls that have been extended. The container of
the Custom button array has registered a Hidden Field in the "OnPreRender"
override method like so :

<DefaultProperty("Text"), ToolboxData("<{0}:ChemicalSubstanceChart
runat=server></{0}:ChemicalSubstanceChart>")> _
Public Class ChemicalSubstanceChart
Inherits System.Web.UI.WebControls.WebControl

Protected _chemButtonArray() As CustomButton

..... blah blah .... some properties ......

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
MyBase.OnPreRender(e)
If Not Page Is Nothing Then
Page.RegisterHiddenField(Me.MyHiddenFieldID, "")
End If
End Sub


Protected Overrides Sub Render (ByVal output as
System.Web.UI.HtmlTextWriter)
Try
Dim i As Integer
For i = 0 To Me._chemButtonArray.Length - 1
Me._chemButtonArray(i).RenderControl(output)
Next
Catch ex As Exception
'Handle The Exception In A Custom Way
End Try
End Sub

End Class


And here is my CustomButton Class that I want to Register a Client-Side
Script Block in the OnPreRender method.


<DefaultProperty("Text"), ToolboxData("<{0}:CustomButton
runat=server></{0}:CustomButton>")> _
Public Class CustomButton
Inherits System.Web.UI.WebControls.Button

..... blah blah .... some properties ......

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
Page.RegisterClientScriptBlock("test","<script
language=""javascript"">function broken{alert('test');}</script>")
End Sub


Protected Overrides Sub Render (ByVal output as
System.Web.UI.HtmlTextWriter)
Me.Render(output)
End Sub

End Class



Why is the CustomButton Class NOT Executing OnPreRender?? I would really,
really, really like it to. Any ideas?


Thanks,

Chad
 
S

Sven

Try to make your CustomButtons childs of your chart or call
OnPreRender by your own.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top