Solved

User control not loading

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

12 Experts available now in Live!

Get 1:1 Help Now