fizch
asked on
User control not loading
I've got a user control that I have created named ContentPane. The page is very simplistic yet it is not showing up on the page when the page loads. I've tried to add the control to the page using the designer, and at run-time and I have no luck either way. I have placed some code in the page_load of the control to add a label to the control and I set a break point there. The event fires, and everything looks fine, but it does not get rendered. I'll include the code that I am using for the user control. I think it is pretty funny that my content pane won't show any content. It's kind of ironic.
User control Html:
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="ContentPane.as cx.vb" Inherits="PeCON.Presentati onLayer.Co ntentPane" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<div align="center" class="ContentPane" id="divContent" runat="server">
<img class="ContainerTopLeft" src="images\cont-tl.gif">
<img class="ContainerTopRight" src="images\cont-tr.gif">
<img class="ContainerBottomLeft " src="images\cont-bl.gif">
<img class="ContainerBottomRigh t" src="images\cont-br.gif">
Hello!!!!!!
</div>
User control code-behind:
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace PresentationLayer
Public Class ContentPane
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
End Sub
Protected WithEvents divContent As System.Web.UI.HtmlControls .HtmlGener icControl
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara tion As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim requestValues As New Label
For Each name As String In Request.ServerVariables
requestValues.Text += name & " = " & Request.ServerVariables(na me) & "<BR>"
Next
divContent.Controls.Add(re questValue s)
End Sub
Public Overrides ReadOnly Property Controls() As ControlCollection
Get
Return divContent.Controls
End Get
End Property
End Class
End Namespace
User control Html:
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="ContentPane.as
<div align="center" class="ContentPane" id="divContent" runat="server">
<img class="ContainerTopLeft" src="images\cont-tl.gif">
<img class="ContainerTopRight" src="images\cont-tr.gif">
<img class="ContainerBottomLeft
<img class="ContainerBottomRigh
Hello!!!!!!
</div>
User control code-behind:
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace PresentationLayer
Public Class ContentPane
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
End Sub
Protected WithEvents divContent As System.Web.UI.HtmlControls
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim requestValues As New Label
For Each name As String In Request.ServerVariables
requestValues.Text += name & " = " & Request.ServerVariables(na
Next
divContent.Controls.Add(re
End Sub
Public Overrides ReadOnly Property Controls() As ControlCollection
Get
Return divContent.Controls
End Get
End Property
End Class
End Namespace
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Public ReadOnly Property Content() As ControlCollection
Get
Return divContent.Controls
End Get
End Property