Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page_Load called twice???

Reply
Thread Tools

Page_Load called twice???

 
 
Andy
Guest
Posts: n/a
 
      10-17-2003
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!

 
Reply With Quote
 
 
 
 
Bret Mulvey [MS]
Guest
Posts: n/a
 
      10-18-2003
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
InitializeComponents() code to attach Page_Load to the OnLoad event.

"Andy" <> wrote in message
news:2d8ef01c394c3$48eb2750$...
> 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!
>



 
Reply With Quote
 
 
 
 
Rick Strahl [MVP]
Guest
Posts: n/a
 
      10-18-2003
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" <> wrote in message
news:2d8ef01c394c3$48eb2750$...
> 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!
>



 
Reply With Quote
 
Saravana [MVP]
Guest
Posts: n/a
 
      10-18-2003
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" <> wrote in message
news:2d8ef01c394c3$48eb2750$...
> 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!
>



 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      10-20-2003
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(EventArgs e)
{
InitializeComponent();
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!
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Materpage page_load event fired after content page_load? rockdale ASP .Net 1 11-16-2006 06:59 PM
in VB.NET Page_load of a base class called after the derived class Page_load ? z. f. ASP .Net 0 10-19-2004 12:01 PM
Why does page_load fire twice when inheriting from a common overridable Page_Load bminder ASP .Net 1 02-23-2004 08:54 PM
Page_Load is called 12 times? George Ter-Saakov ASP .Net 3 12-03-2003 12:28 AM
Re: Determinig what events will be called from Page_Load ??? John Saunders ASP .Net 4 08-22-2003 09:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57