Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Page_Load called twice in child user control--AutoEventWireup=false

Reply
Thread Tools

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

 
 
GJB
Guest
Posts: n/a
 
      05-05-2004
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><uc1arent id=Parent1 runat="server"></uc1arent></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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page_load called twice on button click Imran Aziz ASP .Net 6 09-06-2005 01:55 PM
Page_Load and Page_Init get called twice, sometimes! Dot net work ASP .Net 6 11-24-2004 08:04 PM
in VB.NET Page_load of a base class called after the derived class Page_load ? z. f. ASP .Net 0 10-19-2004 12:01 PM
Why does page_load fire twice when inheriting from a common overridable Page_Load bminder ASP .Net 1 02-23-2004 08:54 PM
Page_Load called twice??? Andy ASP .Net 4 10-20-2003 09:00 AM



Advertisments