Solved

User control not loading

Posted on 2006-06-16
2
343 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now