Page_Load event firing twice... wierd!!

S

Shane Bishop

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!
 
S

Shovem

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!
 
W

Wayne Hall

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
 
W

Wayne Hall

... 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.
 
M

Marc Schluper

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top