Problem dynamically adding Custom Web Control.

Discussion in 'ASP .Net' started by Gibble, May 17, 2007.

  1. Gibble

    Gibble Guest

    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.
    Gibble, May 17, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Henry
    Replies:
    2
    Views:
    375
    Brian Henry
    Nov 14, 2004
  2. Gibble
    Replies:
    0
    Views:
    464
    Gibble
    May 17, 2007
  3. Gibble
    Replies:
    0
    Views:
    313
    Gibble
    May 17, 2007
  4. Terry Holland

    Dynamically adding custom control

    Terry Holland, Nov 17, 2005, in forum: ASP .Net Building Controls
    Replies:
    11
    Views:
    307
    Steven Cheng[MSFT]
    Nov 30, 2005
  5. Terry Holland

    Dynamically adding a custom control

    Terry Holland, Nov 23, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    306
    Steven Cheng[MSFT]
    Nov 24, 2005
Loading...

Share This Page