By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,784 Members | 3,536 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,784 IT Pros & Developers. It's quick & easy.

Page_Load event firing twice... wierd!!

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
... 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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.