473,479 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASP.NET 2.0: Page loaded twice on debug.

Hi,

I recently converted an ASP.NET project for framework 2.0. I never had any
problem using VS 2003 but today, debugging a page, I get surprised when I saw
that once debugged the last line, it was automatically debugged another time
since the first line and even the "if (!IsPostBack)..." code was runned (when
it shouldn't, previously was not runned as it should be)... so many variables
are reinitializated and it doesn't runs as it should. Hope I have explained
the problem clearly... anyone has had this problem? Running the same page
with VS 2003 runs only once and fine.

Thanks in advance!!!
Dec 21 '06 #1
2 1459
Tomás MartÃ*nez wrote:
Hi,

I recently converted an ASP.NET project for framework 2.0. I never
had any problem using VS 2003 but today, debugging a page, I get
surprised when I saw that once debugged the last line, it was
automatically debugged another time since the first line and even the
"if (!IsPostBack)..." code was runned (when it shouldn't, previously
was not runned as it should be)... so many variables are
reinitializated and it doesn't runs as it should. Hope I have
explained the problem clearly... anyone has had this problem? Running
the same page with VS 2003 runs only once and fine.
This is an issue I ran into a couple of times myself as well, and it's
due to a change in ASP.NET: in ASP.NET 1.x, Autowire events was set to
false and teh Load event handler (Page_Load) was bound in a generated
method in the code behind file.

In ASP.NET 2.0, autowire events (in the PAGE directive in the aspx
html code) is set to true by default and this already binds the
page_load event handler routine to the Load event of the page
automatically. So if you migrate a page to ASP.NET 2.0, and you set
autowire events to true in the page tag in the html, AND you have the
page_load event handler bound by code in the code behind as well (check
the generated region in the code behind for this), you'll get a call to
the page_load routine TWICE as the routine is bound to the event twice
(once automatically and once through the .net 1.x code in the generated
region).

so simply remove handler setup in the generated code region and you're
set :).

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Dec 21 '06 #2
Hi!

First of all, thanks for your reply!!! :) So... I understand you tell me to
remove this line

this.Load += new System.EventHandler(this.Page_Load);

in the InitializeComponent(), don't you? The problem is that I don't have
this, but maybe I didn't understand you. Thanks again and sorry about disturb.

"Frans Bouma [C# MVP]" wrote:
Tomás MartÃ*nez wrote:
Hi,

I recently converted an ASP.NET project for framework 2.0. I never
had any problem using VS 2003 but today, debugging a page, I get
surprised when I saw that once debugged the last line, it was
automatically debugged another time since the first line and even the
"if (!IsPostBack)..." code was runned (when it shouldn't, previously
was not runned as it should be)... so many variables are
reinitializated and it doesn't runs as it should. Hope I have
explained the problem clearly... anyone has had this problem? Running
the same page with VS 2003 runs only once and fine.

This is an issue I ran into a couple of times myself as well, and it's
due to a change in ASP.NET: in ASP.NET 1.x, Autowire events was set to
false and teh Load event handler (Page_Load) was bound in a generated
method in the code behind file.

In ASP.NET 2.0, autowire events (in the PAGE directive in the aspx
html code) is set to true by default and this already binds the
page_load event handler routine to the Load event of the page
automatically. So if you migrate a page to ASP.NET 2.0, and you set
autowire events to true in the page tag in the html, AND you have the
page_load event handler bound by code in the code behind as well (check
the generated region in the code behind for this), you'll get a call to
the page_load routine TWICE as the routine is bound to the event twice
(once automatically and once through the .net 1.x code in the generated
region).

so simply remove handler setup in the generated code region and you're
set :).

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Dec 21 '06 #3

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

Similar topics

7
2697
by: Patrick Ruhnow | last post by:
Hello, i have an ASP Page that generates a PDF document. After the generation i save the generated document as a file. all works fine. the only strange thing is, that my document is stored...
2
3796
by: anonieko | last post by:
Scenario: You have a page that is TOO slow to refresh. But it allows partial flushing of html contents. I.e. Submit button already appears but you don't want your users to click on it prematurely...
5
2905
by: Tim | last post by:
I have block of code adding values to dropdown list under if (!Page.IsPostBack) { adding items } else { refreshing data }
0
5707
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
4
2048
by: Jeremy Holt | last post by:
Hi, In a windows.forms application I would BeginInvoke a delegate on the UI thread to collect data from a database. When the call returns to the AsyncCallback, if the Control.InvokeRequired =...
10
2891
by: RDI | last post by:
What's it mean? My prog runs fine. Then as soon as I press ok or cancel, the following is what's in the output area of the debugger. TIA -- RDI (remove the exclamation from the email...
22
2268
by: Christopher Nelson | last post by:
I have a little menu system which essentially takes HTML like: <div id='foo'></div> and retrieves foo.shtml from the server and inserts it inside the <div>. But sometimes I'd like foo.shtml...
4
1710
by: moondaddy | last post by:
I have a .net 1.1 winforms app that calls an aspx page which I need to debug. I also need to start the debugging process from the winform because the winform first calls a web service which passed...
3
1214
by: Achim Domma | last post by:
Hi, I have a weird problem, which is quite hard to debug: An ascx-Control seems to be constructed and processed twice. The AutoEventWireup attribute is set to true. Looking at google, I found a...
0
7027
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
6899
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
7067
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
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
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...
0
2980
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...
0
1288
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 ...
1
555
muto222
php
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.