473,394 Members | 1,715 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,394 software developers and data experts.

Page_Load called twice???

Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #1
8 9539
Is it Page_Load, OnInit, or both? If it's just Page_Load, check if those
two forms have AutoEventWireup="true" in addition to VS.NET's
InitializeComponents() code to attach Page_Load to the OnLoad event.

"Andy" <an****@stagg.info> wrote in message
news:2d*****************************@phx.gbl...
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #2
Is it Page_Load, OnInit, or both? If it's just Page_Load, check if those
two forms have AutoEventWireup="true" in addition to VS.NET's
InitializeComponents() code to attach Page_Load to the OnLoad event.

"Andy" <an****@stagg.info> wrote in message
news:2d*****************************@phx.gbl...
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #3
Hi Andy,

IN addition to what Bret said - is this page subclassed from another? In
that case you may have the page constructor for both pages firing which
means Page_Load() gets called twice...
+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
----------------------------------
Making waves on the Web
"Andy" <an****@stagg.info> wrote in message
news:2d*****************************@phx.gbl...
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #4
Check out this faq, this might help you.
http://www.extremeexperts.com/Net/FA...ringTwice.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

"Andy" <an****@stagg.info> wrote in message
news:2d*****************************@phx.gbl...
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #5
Hi Andy,

IN addition to what Bret said - is this page subclassed from another? In
that case you may have the page constructor for both pages firing which
means Page_Load() gets called twice...
+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
----------------------------------
Making waves on the Web
"Andy" <an****@stagg.info> wrote in message
news:2d*****************************@phx.gbl...
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #6
Check out this faq, this might help you.
http://www.extremeexperts.com/Net/FA...ringTwice.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

"Andy" <an****@stagg.info> wrote in message
news:2d*****************************@phx.gbl...
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

Nov 17 '05 #7
I think it's the Oninit thats being called twice, the
sequence of events is as follows

This bit of code is fired first-

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

then the Page_Load is fired
then back to OnInit
then back to Page_Load

All pages have AutoEventWireup set to false.

Cheers Andy
-----Original Message-----
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

.

Nov 17 '05 #8
I think it's the Oninit thats being called twice, the
sequence of events is as follows

This bit of code is fired first-

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

then the Page_Load is fired
then back to OnInit
then back to Page_Load

All pages have AutoEventWireup set to false.

Cheers Andy
-----Original Message-----
Visual Studio 2003 web form problem using C#.

My Page_Load or OnInit routines seems to be called twice
for every post back to the server.

I have 2 web forms that produce this behaviour, all of
the others just run these routines once.

Any ideas!

.

Nov 17 '05 #9

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...
4
by: Ed | last post by:
Has anyone seen this one? I have a situation where code in my page_load event is firing twice for mozilla firefox users. Everything is fine in IE6. I set breakpoints and verified. The second time...
6
by: Dot net work | last post by:
I've read quite a few threads on these groups about this. When someone says the following: "My Page_Load gets called twice on a button click postback" The replies are: "Do you have...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
9
by: mosscliffe | last post by:
I am sorry but I am all very new and slow at understanding all this ASP.NET2. I found some code which showed how to page with a repeater. All very excited as I had been looking for this all...
4
by: Greg | last post by:
I've searched everywhere for a solution Microsoft .NET Framework V 2.0.50727 AutoEventWireup="false" image2.aspx resize an image on the fly but Page_Load is triggered twice: Any suggestion?...
11
by: fiefie.niles | last post by:
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a sub mySub that does not do anything (for testing purposes). But, Page_Load gets called twice. On every single ASPX page in my...
4
by: TarTar | last post by:
Hello, I have already posted this problem, but I have not received any response yet. I will try to describe it again. We have a list control (e.g. DataList) and an ObjectDataSource on an...
4
by: Paul | last post by:
I have a problem with asp.net 2.0 I've never seen before. On loading the page it loads twice and IsPostback is false both times. This happens if I use: Response.Redirect("somepage.aspx"); I've...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.