![]() |
Page_Load called twice in child user control--AutoEventWireup=false
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 |
| All times are GMT. The time now is 03:39 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.