Solved

User control not loading

Posted on 2006-06-16
2
346 Views
Last Modified: 2008-02-01
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.ascx.vb" Inherits="PeCON.PresentationLayer.ContentPane" 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="ContainerBottomRight" 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.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub
        Protected WithEvents divContent As System.Web.UI.HtmlControls.HtmlGenericControl

        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration 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(name) & "<BR>"
            Next

            divContent.Controls.Add(requestValues)
        End Sub

        Public Overrides ReadOnly Property Controls() As ControlCollection
            Get
                Return divContent.Controls
            End Get
        End Property
    End Class
End Namespace
0
Comment
Question by:fizch
2 Comments
 
LVL 6

Author Comment

by:fizch
ID: 16921260
Nevermind. I found that overriding the Controls property was creating problems. When I changed it to not override the controls property of the base class, it worked. Here is my solution.

        Public ReadOnly Property Content() As ControlCollection
            Get
                Return divContent.Controls
            End Get
        End Property
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 16922470
Closed, 500 points refunded.
Netminder
Site Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question