Page_Load called twice in child user control--AutoEventWireup=false

G

GJB

Hello

I have an application which has a user control on an ASPx page. This user control programmatically adds another user control to its Control collection in its Page_Load event handler. The child user control adds a web control in its Page_Load event handler

AutoEventWireup is set to "false" for both ASCX pages (and the default.aspx page)

The child user control's Page_Load is being called twice

Can anyone explain this

Regards
Glen
------------------------------------------------------------
Here is the full source code

default.aspx
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb" Inherits="TestEmbedUC.WebForm1"%><%@ Register TagPrefix="uc1" TagName="Parent" Src="Parent.ascx" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><title>Test Embedded User Controls...</title></HEAD><body><uc1:parent id=Parent1 runat="server"></uc1:parent></body></HTML

Parent.ascx
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Parent.ascx.vb" Inherits="TestEmbedUC.Parent" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %

Parent.ascx.vb
Public Class Paren
Inherits System.Web.UI.UserContro

#Region " Web Form Designer Generated Code

'This call is required by the Web Form Designer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent(

End Su

'NOTE: The following placeholder declaration is required by the Web Form Designer
'Do not delete or move it
Private designerPlaceholderDeclaration As System.Objec

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Ini
'CODEGEN: This method call is required by the Web Form Designe
'Do not modify it using the code editor
InitializeComponent(
End Su

#End Regio

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
Controls.Add(New LiteralControl("<p>Inside Parent's Page_Load...</p>")
Controls.Add(New Child
End Su

End Clas

Child.ascx
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Child.ascx.vb" Inherits="TestEmbedUC.Child" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %

Child.ascx.vb
Public Class Chil
Inherits System.Web.UI.UserContro

#Region " Web Form Designer Generated Code

'This call is required by the Web Form Designer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent(

End Su

'NOTE: The following placeholder declaration is required by the Web Form Designer
'Do not delete or move it
Private designerPlaceholderDeclaration As System.Objec

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Ini
'CODEGEN: This method call is required by the Web Form Designe
'Do not modify it using the code editor
InitializeComponent(
End Su

#End Regio

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
Controls.Add(New LiteralControl("<p>Inside Child's Page_Load...</p>")
End Su

End Clas
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top