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

Page_Load event firing twice... wierd!!

I've been fighting with the Page_Load event firing twice.
I looked through this user group and saw several other people having
similar problems.
There were various reasons for it:
AutoEventWireup="true" instead of AutoEventWireup="false"
Spyware software
And having your events all wired wrong

I had done everything to my machine, stripped it down to just have
..NET on it and I was still having this problem until...

I changed the page name.
That's right, I changed the page name from default.aspx to index.aspx.
It doesn't happen any more.
I'm not for sure why, but when I would create a default.aspx, VS.NET
would give it a code behind page with a class name of _Default.
Even when I changed the page name to index.aspx, I still had the
default.aspx page in the directory. After the Page_Load event would
fire in index.aspx it would also fire in default.aspx even though I
wasn't hitting that page.
VERY WIERD!!!!!
So noone has to go through the trial/error I had to go through, try
this if you are having the same trouble.
If anyone can explain this phenomenon to me, I would greatly
appreciate it!
Nov 18 '05 #1
7 2322
Shane,

Can you post your code ?

--
Regards,

HD
Once a Geek.... Always a Geek
"Shane Bishop" <s_********@yahoo.com> wrote in message
news:d0**************************@posting.google.c om...
I've been fighting with the Page_Load event firing twice.
I looked through this user group and saw several other people having
similar problems.
There were various reasons for it:
AutoEventWireup="true" instead of AutoEventWireup="false"
Spyware software
And having your events all wired wrong

I had done everything to my machine, stripped it down to just have
.NET on it and I was still having this problem until...

I changed the page name.
That's right, I changed the page name from default.aspx to index.aspx.
It doesn't happen any more.
I'm not for sure why, but when I would create a default.aspx, VS.NET
would give it a code behind page with a class name of _Default.
Even when I changed the page name to index.aspx, I still had the
default.aspx page in the directory. After the Page_Load event would
fire in index.aspx it would also fire in default.aspx even though I
wasn't hitting that page.
VERY WIERD!!!!!
So noone has to go through the trial/error I had to go through, try
this if you are having the same trouble.
If anyone can explain this phenomenon to me, I would greatly
appreciate it!

Nov 18 '05 #2
I haven't been able to reproduce this problem again. I think that it
was either a codebehind type-o or something of that nature.

It was so wierd, until I deleted that default.aspx page, no matter what
page I called in that same directory, the default.aspx's pageload event
got called.

Once I deleted the default.aspx page and everything worked fine. As
soon as I added a brand new default.aspx the same thing continued to
happen again. I've been trying to get it to happen again, and I haven't
been able to.

Thanks for your quick reply!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
Are there more than 1 default.aspx files in the project?
Thanks,
Shawn

"Shovem" <ca***********@nowhere.com> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
I haven't been able to reproduce this problem again. I think that it
was either a codebehind type-o or something of that nature.

It was so wierd, until I deleted that default.aspx page, no matter what
page I called in that same directory, the default.aspx's pageload event
got called.

Once I deleted the default.aspx page and everything worked fine. As
soon as I added a brand new default.aspx the same thing continued to
happen again. I've been trying to get it to happen again, and I haven't
been able to.

Thanks for your quick reply!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4
Ok. Nice to know I am not alone in this...

I have been trying to figure out this "posting twice" thing for 2 days.
I pushed the .Net code to my home, and the problem doesn't happen.

I load a page, enter/edit data, post. Everything posts to the db fine
and the code to redirect to another page is processed... but then the
[posted] page hits its Page_Load method again !! This time, when it
tries to write to the db (Page.IsPostBack is still true), the page's
timestamp doesn't match the db's timestamp so my error routine kicks in.

I added another WebPage to my project, copied the code from the "bad"
page to the new page, and everything runs as it did in the original...
posting twice.

Again, this very same code runs at my house (same environment) just
fine!!!

Any ideas? Please???

Environment at work and at home:
Windows XP Pro, IIS 5, .Net 2003 (C#), IE 6.

Thank you.

-- Wayne
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5
... and another thing. The "posting twice" issue only happens when I
make a change to a text field on the form. I can change selected combo
fields all day long and post successully (once!).

If I add 'TextMode="MultiLine" Rows="0"' to the asp:textbox then the
page will post successfully (once), also.

I am baffled.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #6
It happens in my application too. That is, for SOME pages, typically
pages that display a PDF file (generated by Crystal Reports). I have
AutoEventWireup="false" on all pages. Other pages work fine.
Actually, it's not only the Page_Load; the object on the CodeBehind page
is instantiated twice (the constructor is called twice).

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #7
I found this on Google:
Microsoft .NET Framework 1.1 Page_Load Event Fires Two Times

http://support.microsoft.com/default...b;EN-US;827801

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #8

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

Similar topics

7
by: | last post by:
Hello to all I'm handling the Validating event for one text box. If something is wrong in user input I show a warning message. The problem is that if I add to method the message is displayed...
0
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
by: Larry Morris | last post by:
The following code, pasted into a web form with a link button on it, will cause the page_unload event to fire twice. If I remove the response.redirect, the problem goes away :). I've got a work...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
4
by: C M Shaw | last post by:
I have a form which I want to show modally; it's a fairly old form that's been ported up several versions of VB, and I'd like to keep its rewriting to a minimum. Basically, it is used in this...
2
by: ann | last post by:
I have a datagrid control I am using - the edit & update events are firing twice. I searched on google and see others have had same issue not just with datagrid but with other controls, but no...
2
by: Slim | last post by:
I have loop that builds table rows, it also attaches events, this works fine on all but the last row, where the event fires twice I have autowireup set to false any ideas? For i = 0 To...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.