473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Page Load event fires twice

Hi,

I have a BasePage class from which all other ASPX pages of the project is inherited. The BasePage class implements Page_Load event handler. All child pages have its AutoEventWireUp property set to false.

I have included the code used to create the BasePage and one of the child pages below.

// Class BasePage

public class BasePage : Page
{
// To be overriden by child web pages to intialize page on
// page load event
virtual protected void PageLoadEvent(object sender, System.EventArgs e)
{}

protected void Page_Load(object sender, System.EventArgs e)
{
BuildMenu();
}

}

Nov 18 '05 #1
1 6032
Please ignore the previous post of mine, it is incomplete. I have provided a complete description of my problem in this post.

----------------------------------------------------------------------------------------------------------------------------

I have a BasePage class from which all other ASPX pages of the project is inherited. The BasePage class implements Page_Load event handler. All child pages have its AutoEventWireUp property set to false.

I have included the code used to create the BasePage and one of the child pages below.

----------------------------------------------------------------------------------------------------------------------------
// BasePage class declaration begins here

public class BasePage : Page
{
// To be overriden by child web pages to intialize page on
// page load event
virtual protected void PageLoadEvent(object sender, System.EventArgs e)
{}

protected void Page_Load(object sender, System.EventArgs e)
{
BuildMenu();
}

private void BuildMenu()
{
//Includes code to construct popup menu dynamically
//...
//..
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}//end of BasePage class declaration
----------------------------------------------------------------------------------------------------------------------------
//ChildPage.aspx
//From HTML view
<%@ Page language="c#" Codebehind="ChildPage.aspx.cs" AutoEventWireup="false" Inherits="ChildPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Home Page</TITLE>
<META content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<META content="C#" name="CODE_LANGUAGE">
<META content="JavaScript" name="vs_defaultClientScript">
<META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<BODY leftMargin="0" topMargin="0" MS_POSITIONING="GridLayout">
<FORM id="frmSearch" method="post" runat="server">
<TABLE>
<TR >
<TD align="center" colSpan="4><ASP:TEXTBOX id="txtKeyword" runat="server" Width="190px"></ASP:TEXTBOX></TD>
</TR>
<TR >
<TD align="center" colSpan="4"><ASP:BUTTON id="cmdOK" runat="server" Text="Search"></ASP:BUTTON>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

//From Code-behind file - ChildPage.aspx .cs

public class ChildPage: BasePage
{
protected System.Web.UI.WebControls.TextBox txtKeyword;
protected System.Web.UI.WebControls.Button cmdOK;

protected override void PageLoadEvent(object sender, System.EventArgs e)
{
//Displays logged on users details on the page
DisplayLogonInfo();
}
private void DisplayLogonInfo()
{
//Include code for displaying looged on user's information
//...
//...
}
private void cmdOK_Click(object sender, System.EventArgs e)
{
//Processes OK button click
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
}
#endregion
}//End of ChildPage class declaration

----------------------------------------------------------------------------------------------------------------------------
Could anyone tell me how to prevent the Page_Load event from getting fired twice?

Thanks in advance.

Regards,
Magdelin



Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Colin Basterfield | last post by:
Hi, Hmmm, a strange one for me, but hopefully not for others... I have a base page which has virtual protected void PageLoadEvent(object sender, System.EventArgs e){} In the Page_Load...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
5
by: Asa Monsey | last post by:
I am having a problem that the page load event fires twice in reponse to an autopostback. The first time, the IsPostBack property is true, and the second time it it false. This is causing many...
1
by: PCH | last post by:
Hello all, Been messing the the dec CTP of .net 2 Heres the situation: I have a master page with the contents control and a button control (call it btnRefresh). I have a child page that...
1
by: Bill Manring | last post by:
The startup page for my ASP.NET application is an HTML frames page with two frames. This seems to cause the Session_Start event in the Global.asax file to fire twice. When I change the startup...
8
by: MaryA | last post by:
I have an aspx page that loads twice inspite of using the IsPostBack i removed all controls from the page and still the page_load event is called twice I appriciate any help coz i have lost...
8
by: TS | last post by:
Hi, i have inherited a page from another user. The page is the target frame in a frameset. for some reason the whole page runs twice (page_load, init, etc. all run twice) I can't figure out how...
0
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and...
0
by: manywolf | last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.