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

Discussion in 'ASP .Net Building Controls' started by GJB, May 5, 2004.

  1. GJB

    GJB Guest

    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
     
    GJB, May 5, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bminder
    Replies:
    1
    Views:
    2,212
    nfedin
    Feb 23, 2004
  2. z. f.
    Replies:
    0
    Views:
    589
    z. f.
    Oct 19, 2004
  3. magister
    Replies:
    2
    Views:
    3,615
    magister
    Nov 1, 2004
  4. Replies:
    0
    Views:
    725
  5. Tim_Mac
    Replies:
    27
    Views:
    6,250
    Steven Cheng[MSFT]
    Feb 9, 2007
Loading...

Share This Page