473,748 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9560
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
InitializeCompo nents() code to attach Page_Load to the OnLoad event.

"Andy" <an****@stagg.i nfo> 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
InitializeCompo nents() code to attach Page_Load to the OnLoad event.

"Andy" <an****@stagg.i nfo> 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.i nfo> 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.i nfo> 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.i nfo> 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.i nfo> 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(EventArg s e)
{
InitializeCompo nent();
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(EventArg s e)
{
InitializeCompo nent();
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
6426
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 method I call this
4
1713
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 the page_load fires in mozilla, I checked the IsPostback to verify that it is still false. What causes this behavior? Thanks, Ed
6
6011
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 AutoEventWireup=True in your page header?" In my project, I have this set to false - everywhere.
3
8811
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 twice, once with postback true, and second time without postback. This only happens for this button. How can I sort out this issue, any clues what to look for to get this sorted please. <p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
9
4745
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 day. It worked wonderfully, but it was in C# So I converted it to VB with http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx It got upset about private and so I changed those to protected
4
3817
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? Here is the code behind:
11
2701
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 site, Page_Load gets called twice. Why is that and how can I fix this problem ? Thank you very much. Imports System.IO Namespace myProject Partial Class WebForm1
4
4701
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 ASP.NET web page. When we open the page the Select method (here: GetCustomers) is called twice. Why? It is obvious performance hit as the data needs to be retrieved twice. How to avoid the duplicated calls?
4
4037
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 never had this problem on a page before. But with Server.Transfer the problem goes away, but why? Server.Transfer("somepage.aspx");
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.