Problem dynamically adding Custom Web Control.

G

Gibble

Hi,
I can't seem to get my control to render properly. When I just placed
it on the page it was working fine...and the RenderContents sub is
getting fired...I'm guessing it's just too late???

The HoverMenuExtender renders, the PopPanel renders, and the Literal
(Hello World) renders on the page. But my MiniExhibitPopup does not.

Here's the pertinent code:

Partial Public Class _Default
Inherits System.Web.UI.Page

Protected Overrides Sub CreateChildControls()

For i As Integer = 1 To 10
Dim Panel As System.Web.UI.WebControls.Panel =
CType(Page.FindControl("ME" + i.ToString),
System.Web.UI.WebControls.Panel)

Dim PopPanel As New System.Web.UI.WebControls.Panel
With PopPanel
.ID = "PopupMenu" + i.ToString
.CssClass = "MiniExhibitPopup"
.Controls.Add(New MiniExhibitPopup)
.Controls.Add(New LiteralControl("Hello World!"))
End With
Page.Form.Controls.Add(PopPanel)

Dim HoverMenuExtender As New
AjaxControlToolkit.HoverMenuExtender
With HoverMenuExtender
.ID = "h" + Panel.ID
.PopupControlID = PopPanel.ID
.PopupPosition =
AjaxControlToolkit.HoverMenuPopupPosition.Center
.TargetControlID = Panel.ID
.PopDelay = 500
End With
Page.Form.Controls.Add(HoverMenuExtender)
Next
End Sub
End Class


Public Class MiniExhibitPopup
Inherits WebControl

Protected Overrides Sub RenderContents(ByVal writer As
HtmlTextWriter)
Dim html As String
Dim objReader As IO.StreamReader

Try
objReader = New StreamReader(Context.Server.MapPath("~/
Controls/MiniExhibitPopup/MiniExhibitPopup.htm"))
html = objReader.ReadToEnd()
objReader.Close()
Catch Ex As Exception
Throw Ex
End Try

html = html.Replace("##EXHIBITNAME##", "The Chadwikiti Hut")
html = html.Replace("##USERNAME##", "Chad Hurd")
html = html.Replace("##DESCRIPTION##", "Lorum Ipsum Lorum
Ipsum Lorum Ipsum Lorum Ipsum Lorum Ipsum Lorum Ipsum Lorum Ipsum
Lorum Ipsum ")
html = html.Replace("##ATTENDEES##", "0")
html = html.Replace("##USERIMAGE##", "/Images/face.jpg")

writer.Write(html)
End Sub
End Class



Please help. Thanks,

Chad.
 

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,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top