Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Page_Load gets called twice

 
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      04-29-2007
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a
sub mySub that does not do anything (for testing purposes). But,
Page_Load gets called twice.
On every single ASPX page in my site, Page_Load gets called twice. Why
is that and how can I fix this problem ?
Thank you very much.

Imports System.IO
Namespace myProject
Partial Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents HyperLink1 As
System.Web.UI.WebControls.HyperLink

#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region

Protected Sub Page_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load, Me.Load
mySub()
End Sub
Sub mySub()
End Sub
End Class
End Namespace

 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      04-30-2007
Are you setting AutoEventWireup to true
(or are you not defining it, since by default it is true) ?

Page events are automatically bound to methods that use the naming convention of
Page_event, such as Page_Load, when you set AutoEventWireup to true or not set it to false.

If you set AutoEventWireup to true, and then use the Handles statement,
you will get Page events called twice, once by AutoEventWireup,
and again when you use Handles.

Test by setting AutoEventWireup to false, or by eliminating the Handles statement.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
<> wrote in message
news: oups.com...
>I am using ASP.NET 2005 and I have a simple form. Page_Load calls a
> sub mySub that does not do anything (for testing purposes). But,
> Page_Load gets called twice.
> On every single ASPX page in my site, Page_Load gets called twice. Why
> is that and how can I fix this problem ?
> Thank you very much.
>
> Imports System.IO
> Namespace myProject
> Partial Class WebForm1
> Inherits System.Web.UI.Page
> Protected WithEvents HyperLink1 As
> System.Web.UI.WebControls.HyperLink
>
> #Region " Web Form Designer Generated Code "
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()>
> Private Sub InitializeComponent()
> End Sub
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form
> Designer
> 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
> #End Region
>
> Protected Sub Page_Load(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles MyBase.Load, Me.Load
> mySub()
> End Sub
> Sub mySub()
> End Sub
> End Class
> End Namespace
>




 
Reply With Quote
 
 
 
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      04-30-2007
Thank you for your reply.

>Are you setting AutoEventWireup to true ?

Do I find this in the myPage.aspx ?
This is what it says in myPage.aspx:
<%@ Page Language="vb" AutoEventWireup="false"
Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
I do not define/change it, it is like that already. Does it mean that
it is set to False ?

> Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

How can I eliminate the Handles statement ?

Thank you.


On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> Are you setting AutoEventWireup to true
> (or are you not defining it, since by default it is true) ?
>
> Page events are automatically bound to methods that use the naming convention of
> Page_event, such as Page_Load, when you set AutoEventWireup to true or not set it to false.
>
> If you set AutoEventWireup to true, and then use the Handles statement,
> you will get Page events called twice, once by AutoEventWireup,
> and again when you use Handles.
>
> Test by setting AutoEventWireup to false, or by eliminating the Handles statement.
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: oups.com...
>
>
>
> >I am using ASP.NET 2005 and I have a simple form. Page_Load calls a
> > sub mySub that does not do anything (for testing purposes). But,
> > Page_Load gets called twice.
> > On every single ASPX page in my site, Page_Load gets called twice. Why
> > is that and how can I fix this problem ?
> > Thank you very much.

>
> > Imports System.IO
> > Namespace myProject
> > Partial Class WebForm1
> > Inherits System.Web.UI.Page
> > Protected WithEvents HyperLink1 As
> > System.Web.UI.WebControls.HyperLink

>
> > #Region " Web Form Designer Generated Code "
> > 'This call is required by the Web Form Designer.
> > <System.Diagnostics.DebuggerStepThrough()>
> > Private Sub InitializeComponent()
> > End Sub

>
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > As System.EventArgs) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form
> > Designer
> > 'Do not modify it using the code editor.
> > InitializeComponent()
> > End Sub
> > #End Region

>
> > Protected Sub Page_Load(ByVal sender As System.Object, ByVal e
> > As System.EventArgs) Handles MyBase.Load, Me.Load
> > mySub()
> > End Sub
> > Sub mySub()
> > End Sub
> > End Class
> > End Namespace- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      04-30-2007
re:
!> This is what it says in myPage.aspx:
!> <%@ Page Language="vb" AutoEventWireup="false"
!> Does it mean that it is set to False ?

Yes, it is set to false.

re:
> How can I eliminate the Handles statement ?


Since you already have AutoEventWireup set to false, all you have to do is eliminate
the double-loading of the code base. i.e., you currently have this :

Protected Sub Page_Load(...) Handles MyBase.Load, Me.Load

That loads the code twice ( once with MyBase.Load and again with Me.Load )
In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.

Use :
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load

If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :

Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
<> wrote in message
news: oups.com...
Thank you for your reply.

>Are you setting AutoEventWireup to true ?

Do I find this in the myPage.aspx ?
This is what it says in myPage.aspx:
<%@ Page Language="vb" AutoEventWireup="false"
Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
I do not define/change it, it is like that already. Does it mean that
it is set to False ?

> Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

How can I eliminate the Handles statement ?

Thank you.


On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> Are you setting AutoEventWireup to true
> (or are you not defining it, since by default it is true) ?
>
> Page events are automatically bound to methods that use the naming convention of
> Page_event, such as Page_Load, when you set AutoEventWireup to true or not set it to false.
>
> If you set AutoEventWireup to true, and then use the Handles statement,
> you will get Page events called twice, once by AutoEventWireup,
> and again when you use Handles.
>
> Test by setting AutoEventWireup to false, or by eliminating the Handles statement.
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================

<fiefie.ni...@gmail.com> wrote in message
>
> news: oups.com...
>
>
>
> >I am using ASP.NET 2005 and I have a simple form. Page_Load calls a
> > sub mySub that does not do anything (for testing purposes). But,
> > Page_Load gets called twice.
> > On every single ASPX page in my site, Page_Load gets called twice. Why
> > is that and how can I fix this problem ?
> > Thank you very much.

>
> > Imports System.IO
> > Namespace myProject
> > Partial Class WebForm1
> > Inherits System.Web.UI.Page
> > Protected WithEvents HyperLink1 As
> > System.Web.UI.WebControls.HyperLink

>
> > #Region " Web Form Designer Generated Code "
> > 'This call is required by the Web Form Designer.
> > <System.Diagnostics.DebuggerStepThrough()>
> > Private Sub InitializeComponent()
> > End Sub

>
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > As System.EventArgs) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form
> > Designer
> > 'Do not modify it using the code editor.
> > InitializeComponent()
> > End Sub
> > #End Region

>
> > Protected Sub Page_Load(ByVal sender As System.Object, ByVal e
> > As System.EventArgs) Handles MyBase.Load, Me.Load
> > mySub()
> > End Sub
> > Sub mySub()
> > End Sub
> > End Class
> > End Namespace- Hide quoted text -

>
> - Show quoted text -




 
Reply With Quote
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      05-01-2007
Thank you very much for your help.
Your suggestion to eliminate Me.Load from the Page_Load works !
Thanks a lot !

So, I have to do this on every page ?
Do you know why ASP.Net 2005 default both Me.Load and MyBase.Load ?
Is there any need to call up Page_Load twice ?

THanks again for your help.

On Apr 30, 2:59 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> re:
> !> This is what it says in myPage.aspx:
> !> <%@ Page Language="vb" AutoEventWireup="false"
> !> Does it mean that it is set to False ?
>
> Yes, it is set to false.
>
> re:
>
> > How can I eliminate the Handles statement ?

>
> Since you already have AutoEventWireup set to false, all you have to do is eliminate
> the double-loading of the code base. i.e., you currently have this :
>
> Protected SubPage_Load(...) Handles MyBase.Load, Me.Load
>
> That loads the codetwice( once with MyBase.Load and again with Me.Load )
> In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.
>
> Use :
> Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
> MyBase.Load
>
> If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :
>
> Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: oups.com...
> Thank you for your reply.
>
> >Are you setting AutoEventWireup to true ?

>
> Do I find this in the myPage.aspx ?
> This is what it says in myPage.aspx:
> <%@ Page Language="vb" AutoEventWireup="false"
> Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
> I do not define/change it, it is like that already. Does it mean that
> it is set to False ?
>
> > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> How can I eliminate the Handles statement ?
>
> Thank you.
>
> On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> wrote:
>
>
>
> > Are you setting AutoEventWireup to true
> > (or are you not defining it, since by default it is true) ?

>
> > Page events are automatically bound to methods that use the naming convention of
> > Page_event, such asPage_Load, when you set AutoEventWireup to true or not set it to false.

>
> > If you set AutoEventWireup to true, and then use the Handles statement,
> > you will get Page eventscalledtwice, once by AutoEventWireup,
> > and again when you use Handles.

>
> > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > Juan T. Llibre, asp.net MVP
> > asp.net faq :http://asp.net.do/faq/
> > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > ===================================

> <fiefie.ni...@gmail.com> wrote in message
>
> >news: roups.com...

>
> > >I am using ASP.NET 2005 and I have a simple form.Page_Loadcalls a
> > > sub mySub that does not do anything (for testing purposes). But,
> > >Page_Loadgetscalledtwice.
> > > On every single ASPX page in my site,Page_Loadgetscalledtwice. Why
> > > is that and how can I fix this problem ?
> > > Thank you very much.

>
> > > Imports System.IO
> > > Namespace myProject
> > > Partial Class WebForm1
> > > Inherits System.Web.UI.Page
> > > Protected WithEvents HyperLink1 As
> > > System.Web.UI.WebControls.HyperLink

>
> > > #Region " Web Form Designer Generated Code "
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnostics.DebuggerStepThrough()>
> > > Private Sub InitializeComponent()
> > > End Sub

>
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > > As System.EventArgs) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
> > > Designer
> > > 'Do not modify it using the code editor.
> > > InitializeComponent()
> > > End Sub
> > > #End Region

>
> > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e
> > > As System.EventArgs) Handles MyBase.Load, Me.Load
> > > mySub()
> > > End Sub
> > > Sub mySub()
> > > End Sub
> > > End Class
> > > End Namespace- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      05-01-2007
One more info: these pages were converted from ASP.NET 2003 to ASP.NET
2005 using the wizard in Visual Studio 2005. Do you think that's why
all my pages have both MyBase.Load and Me.Load in the Page_Load ?
Thanks

On Apr 30, 2:59 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> re:
> !> This is what it says in myPage.aspx:
> !> <%@ Page Language="vb" AutoEventWireup="false"
> !> Does it mean that it is set to False ?
>
> Yes, it is set to false.
>
> re:
>
> > How can I eliminate the Handles statement ?

>
> Since you already have AutoEventWireup set to false, all you have to do is eliminate
> the double-loading of the code base. i.e., you currently have this :
>
> Protected SubPage_Load(...) Handles MyBase.Load, Me.Load
>
> That loads the codetwice( once with MyBase.Load and again with Me.Load )
> In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.
>
> Use :
> Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
> MyBase.Load
>
> If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :
>
> Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: oups.com...
> Thank you for your reply.
>
> >Are you setting AutoEventWireup to true ?

>
> Do I find this in the myPage.aspx ?
> This is what it says in myPage.aspx:
> <%@ Page Language="vb" AutoEventWireup="false"
> Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
> I do not define/change it, it is like that already. Does it mean that
> it is set to False ?
>
> > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> How can I eliminate the Handles statement ?
>
> Thank you.
>
> On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> wrote:
>
>
>
> > Are you setting AutoEventWireup to true
> > (or are you not defining it, since by default it is true) ?

>
> > Page events are automatically bound to methods that use the naming convention of
> > Page_event, such asPage_Load, when you set AutoEventWireup to true or not set it to false.

>
> > If you set AutoEventWireup to true, and then use the Handles statement,
> > you will get Page eventscalledtwice, once by AutoEventWireup,
> > and again when you use Handles.

>
> > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > Juan T. Llibre, asp.net MVP
> > asp.net faq :http://asp.net.do/faq/
> > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > ===================================

> <fiefie.ni...@gmail.com> wrote in message
>
> >news: roups.com...

>
> > >I am using ASP.NET 2005 and I have a simple form.Page_Loadcalls a
> > > sub mySub that does not do anything (for testing purposes). But,
> > >Page_Loadgetscalledtwice.
> > > On every single ASPX page in my site,Page_Loadgetscalledtwice. Why
> > > is that and how can I fix this problem ?
> > > Thank you very much.

>
> > > Imports System.IO
> > > Namespace myProject
> > > Partial Class WebForm1
> > > Inherits System.Web.UI.Page
> > > Protected WithEvents HyperLink1 As
> > > System.Web.UI.WebControls.HyperLink

>
> > > #Region " Web Form Designer Generated Code "
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnostics.DebuggerStepThrough()>
> > > Private Sub InitializeComponent()
> > > End Sub

>
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > > As System.EventArgs) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
> > > Designer
> > > 'Do not modify it using the code editor.
> > > InitializeComponent()
> > > End Sub
> > > #End Region

>
> > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e
> > > As System.EventArgs) Handles MyBase.Load, Me.Load
> > > mySub()
> > > End Sub
> > > Sub mySub()
> > > End Sub
> > > End Class
> > > End Namespace- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      05-01-2007
re:
!> these pages were converted from ASP.NET 2003 to ASP.NET
!> 2005 using the wizard in Visual Studio 2005. Do you think that's why
!> all my pages have both MyBase.Load and Me.Load in the Page_Load ?

Short answer : yes.





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
<> wrote in message
news: ps.com...
One more info: these pages were converted from ASP.NET 2003 to ASP.NET
2005 using the wizard in Visual Studio 2005. Do you think that's why
all my pages have both MyBase.Load and Me.Load in the Page_Load ?
Thanks

On Apr 30, 2:59 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> re:
> !> This is what it says in myPage.aspx:
> !> <%@ Page Language="vb" AutoEventWireup="false"
> !> Does it mean that it is set to False ?
>
> Yes, it is set to false.
>
> re:
>
> > How can I eliminate the Handles statement ?

>
> Since you already have AutoEventWireup set to false, all you have to do is eliminate
> the double-loading of the code base. i.e., you currently have this :
>
> Protected SubPage_Load(...) Handles MyBase.Load, Me.Load
>
> That loads the codetwice( once with MyBase.Load and again with Me.Load )
> In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.
>
> Use :
> Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
> MyBase.Load
>
> If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :
>
> Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: oups.com...
> Thank you for your reply.
>
> >Are you setting AutoEventWireup to true ?

>
> Do I find this in the myPage.aspx ?
> This is what it says in myPage.aspx:
> <%@ Page Language="vb" AutoEventWireup="false"
> Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
> I do not define/change it, it is like that already. Does it mean that
> it is set to False ?
>
> > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> How can I eliminate the Handles statement ?
>
> Thank you.
>
> On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> wrote:
>
>
>
> > Are you setting AutoEventWireup to true
> > (or are you not defining it, since by default it is true) ?

>
> > Page events are automatically bound to methods that use the naming convention of
> > Page_event, such asPage_Load, when you set AutoEventWireup to true or not set it to false.

>
> > If you set AutoEventWireup to true, and then use the Handles statement,
> > you will get Page eventscalledtwice, once by AutoEventWireup,
> > and again when you use Handles.

>
> > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > Juan T. Llibre, asp.net MVP
> > asp.net faq :http://asp.net.do/faq/
> > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > ===================================

> <fiefie.ni...@gmail.com> wrote in message
>
> >news: roups.com...

>
> > >I am using ASP.NET 2005 and I have a simple form.Page_Loadcalls a
> > > sub mySub that does not do anything (for testing purposes). But,
> > >Page_Loadgetscalledtwice.
> > > On every single ASPX page in my site,Page_Loadgetscalledtwice. Why
> > > is that and how can I fix this problem ?
> > > Thank you very much.

>
> > > Imports System.IO
> > > Namespace myProject
> > > Partial Class WebForm1
> > > Inherits System.Web.UI.Page
> > > Protected WithEvents HyperLink1 As
> > > System.Web.UI.WebControls.HyperLink

>
> > > #Region " Web Form Designer Generated Code "
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnostics.DebuggerStepThrough()>
> > > Private Sub InitializeComponent()
> > > End Sub

>
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > > As System.EventArgs) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
> > > Designer
> > > 'Do not modify it using the code editor.
> > > InitializeComponent()
> > > End Sub
> > > #End Region

>
> > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e
> > > As System.EventArgs) Handles MyBase.Load, Me.Load
> > > mySub()
> > > End Sub
> > > Sub mySub()
> > > End Sub
> > > End Class
> > > End Namespace- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -




 
Reply With Quote
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      05-01-2007
Thanks again.
Do you know if there is ever any need to call up Page_Load twice ?

On Apr 30, 8:14 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> re:
> !> these pages were converted from ASP.NET 2003 to ASP.NET
> !> 2005 using the wizard in Visual Studio 2005. Do you think that's why
> !> all my pages have both MyBase.Load and Me.Load in thePage_Load?
>
> Short answer : yes.
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: ps.com...
> One more info: these pages were converted from ASP.NET 2003 to ASP.NET
> 2005 using the wizard in Visual Studio 2005. Do you think that's why
> all my pages have both MyBase.Load and Me.Load in thePage_Load?
> Thanks
>
> On Apr 30, 2:59 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> wrote:
>
>
>
> > re:
> > !> This is what it says in myPage.aspx:
> > !> <%@ Page Language="vb" AutoEventWireup="false"
> > !> Does it mean that it is set to False ?

>
> > Yes, it is set to false.

>
> > re:

>
> > > How can I eliminate the Handles statement ?

>
> > Since you already have AutoEventWireup set to false, all you have to do is eliminate
> > the double-loading of the code base. i.e., you currently have this :

>
> > Protected SubPage_Load(...) Handles MyBase.Load, Me.Load

>
> > That loads the codetwice( once with MyBase.Load and again with Me.Load )
> > In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.

>
> > Use :
> > Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System..EventArgs) Handles
> > MyBase.Load

>
> > If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :

>
> > Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System..EventArgs)

>
> > Juan T. Llibre, asp.net MVP
> > asp.net faq :http://asp.net.do/faq/
> > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > ===================================<fiefie.ni...@g mail.com> wrote in message

>
> >news: roups.com...
> > Thank you for your reply.

>
> > >Are you setting AutoEventWireup to true ?

>
> > Do I find this in the myPage.aspx ?
> > This is what it says in myPage.aspx:
> > <%@ Page Language="vb" AutoEventWireup="false"
> > Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
> > I do not define/change it, it is like that already. Does it mean that
> > it is set to False ?

>
> > > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > How can I eliminate the Handles statement ?

>
> > Thank you.

>
> > On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> > wrote:

>
> > > Are you setting AutoEventWireup to true
> > > (or are you not defining it, since by default it is true) ?

>
> > > Page events are automatically bound to methods that use the naming convention of
> > > Page_event, such asPage_Load, when you set AutoEventWireup to true or not set it to false.

>
> > > If you set AutoEventWireup to true, and then use the Handles statement,
> > > you will get Page eventscalledtwice, once by AutoEventWireup,
> > > and again when you use Handles.

>
> > > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > > Juan T. Llibre, asp.net MVP
> > > asp.net faq :http://asp.net.do/faq/
> > > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > > ===================================

> > <fiefie.ni...@gmail.com> wrote in message

>
> > >news: roups.com...

>
> > > >I am using ASP.NET 2005 and I have a simple form.Page_Loadcalls a
> > > > sub mySub that does not do anything (for testing purposes). But,
> > > >Page_Loadgetscalledtwice.
> > > > On every single ASPX page in my site,Page_Loadgetscalledtwice. Why
> > > > is that and how can I fix this problem ?
> > > > Thank you very much.

>
> > > > Imports System.IO
> > > > Namespace myProject
> > > > Partial Class WebForm1
> > > > Inherits System.Web.UI.Page
> > > > Protected WithEvents HyperLink1 As
> > > > System.Web.UI.WebControls.HyperLink

>
> > > > #Region " Web Form Designer Generated Code "
> > > > 'This call is required by the Web Form Designer.
> > > > <System.Diagnostics.DebuggerStepThrough()>
> > > > Private Sub InitializeComponent()
> > > > End Sub

>
> > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > > > As System.EventArgs) Handles MyBase.Init
> > > > 'CODEGEN: This method call is required by the Web Form
> > > > Designer
> > > > 'Do not modify it using the code editor.
> > > > InitializeComponent()
> > > > End Sub
> > > > #End Region

>
> > > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e
> > > > As System.EventArgs) Handles MyBase.Load, Me.Load
> > > > mySub()
> > > > End Sub
> > > > Sub mySub()
> > > > End Sub
> > > > End Class
> > > > End Namespace- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      05-01-2007
re:
> Do you know if there is ever any need to call up Page_Load twice ?


None whatsoever.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
<> wrote in message
news: oups.com...
Thanks again.
Do you know if there is ever any need to call up Page_Load twice ?

On Apr 30, 8:14 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> re:
> !> these pages were converted from ASP.NET 2003 to ASP.NET
> !> 2005 using the wizard in Visual Studio 2005. Do you think that's why
> !> all my pages have both MyBase.Load and Me.Load in thePage_Load?
>
> Short answer : yes.
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: ps.com...
> One more info: these pages were converted from ASP.NET 2003 to ASP.NET
> 2005 using the wizard in Visual Studio 2005. Do you think that's why
> all my pages have both MyBase.Load and Me.Load in thePage_Load?
> Thanks
>
> On Apr 30, 2:59 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> wrote:
>
>
>
> > re:
> > !> This is what it says in myPage.aspx:
> > !> <%@ Page Language="vb" AutoEventWireup="false"
> > !> Does it mean that it is set to False ?

>
> > Yes, it is set to false.

>
> > re:

>
> > > How can I eliminate the Handles statement ?

>
> > Since you already have AutoEventWireup set to false, all you have to do is eliminate
> > the double-loading of the code base. i.e., you currently have this :

>
> > Protected SubPage_Load(...) Handles MyBase.Load, Me.Load

>
> > That loads the codetwice( once with MyBase.Load and again with Me.Load )
> > In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.

>
> > Use :
> > Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
> > MyBase.Load

>
> > If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :

>
> > Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

>
> > Juan T. Llibre, asp.net MVP
> > asp.net faq :http://asp.net.do/faq/
> > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > ===================================<fiefie.ni...@g mail.com> wrote in message

>
> >news: roups.com...
> > Thank you for your reply.

>
> > >Are you setting AutoEventWireup to true ?

>
> > Do I find this in the myPage.aspx ?
> > This is what it says in myPage.aspx:
> > <%@ Page Language="vb" AutoEventWireup="false"
> > Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
> > I do not define/change it, it is like that already. Does it mean that
> > it is set to False ?

>
> > > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > How can I eliminate the Handles statement ?

>
> > Thank you.

>
> > On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> > wrote:

>
> > > Are you setting AutoEventWireup to true
> > > (or are you not defining it, since by default it is true) ?

>
> > > Page events are automatically bound to methods that use the naming convention of
> > > Page_event, such asPage_Load, when you set AutoEventWireup to true or not set it to false.

>
> > > If you set AutoEventWireup to true, and then use the Handles statement,
> > > you will get Page eventscalledtwice, once by AutoEventWireup,
> > > and again when you use Handles.

>
> > > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > > Juan T. Llibre, asp.net MVP
> > > asp.net faq :http://asp.net.do/faq/
> > > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > > ===================================

> > <fiefie.ni...@gmail.com> wrote in message

>
> > >news: roups.com...

>
> > > >I am using ASP.NET 2005 and I have a simple form.Page_Loadcalls a
> > > > sub mySub that does not do anything (for testing purposes). But,
> > > >Page_Loadgetscalledtwice.
> > > > On every single ASPX page in my site,Page_Loadgetscalledtwice. Why
> > > > is that and how can I fix this problem ?
> > > > Thank you very much.

>
> > > > Imports System.IO
> > > > Namespace myProject
> > > > Partial Class WebForm1
> > > > Inherits System.Web.UI.Page
> > > > Protected WithEvents HyperLink1 As
> > > > System.Web.UI.WebControls.HyperLink

>
> > > > #Region " Web Form Designer Generated Code "
> > > > 'This call is required by the Web Form Designer.
> > > > <System.Diagnostics.DebuggerStepThrough()>
> > > > Private Sub InitializeComponent()
> > > > End Sub

>
> > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > > > As System.EventArgs) Handles MyBase.Init
> > > > 'CODEGEN: This method call is required by the Web Form
> > > > Designer
> > > > 'Do not modify it using the code editor.
> > > > InitializeComponent()
> > > > End Sub
> > > > #End Region

>
> > > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e
> > > > As System.EventArgs) Handles MyBase.Load, Me.Load
> > > > mySub()
> > > > End Sub
> > > > Sub mySub()
> > > > End Sub
> > > > End Class
> > > > End Namespace- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -




 
Reply With Quote
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      05-01-2007
Thanks !

On Apr 30, 10:58 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
wrote:
> re:
>
> > Do you know if there is ever any need to call upPage_Loadtwice?

>
> None whatsoever.
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ===================================<fiefie.ni...@g mail.com> wrote in message
>
> news: oups.com...
> Thanks again.
> Do you know if there is ever any need to call upPage_Loadtwice?
>
> On Apr 30, 8:14 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> wrote:
>
>
>
> > re:
> > !> these pages were converted from ASP.NET 2003 to ASP.NET
> > !> 2005 using the wizard in Visual Studio 2005. Do you think that's why
> > !> all my pages have both MyBase.Load and Me.Load in thePage_Load?

>
> > Short answer : yes.

>
> > Juan T. Llibre, asp.net MVP
> > asp.net faq :http://asp.net.do/faq/
> > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > ===================================<fiefie.ni...@g mail.com> wrote in message

>
> >news: ups.com...
> > One more info: these pages were converted from ASP.NET 2003 to ASP.NET
> > 2005 using the wizard in Visual Studio 2005. Do you think that's why
> > all my pages have both MyBase.Load and Me.Load in thePage_Load?
> > Thanks

>
> > On Apr 30, 2:59 am, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> > wrote:

>
> > > re:
> > > !> This is what it says in myPage.aspx:
> > > !> <%@ Page Language="vb" AutoEventWireup="false"
> > > !> Does it mean that it is set to False ?

>
> > > Yes, it is set to false.

>
> > > re:

>
> > > > How can I eliminate the Handles statement ?

>
> > > Since you already have AutoEventWireup set to false, all you have to do is eliminate
> > > the double-loading of the code base. i.e., you currently have this :

>
> > > Protected SubPage_Load(...) Handles MyBase.Load, Me.Load

>
> > > That loads the codetwice( once with MyBase.Load and again with Me.Load )
> > > In ASP.NET 1.1 you could get away with that, but 2.0 is a bit stricter.

>
> > > Use :
> > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
> > > MyBase.Load

>
> > > If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :

>
> > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

>
> > > Juan T. Llibre, asp.net MVP
> > > asp.net faq :http://asp.net.do/faq/
> > > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > > ===================================<fiefie.ni...@g mail.com> wrote in message

>
> > >news: roups.com...
> > > Thank you for your reply.

>
> > > >Are you setting AutoEventWireup to true ?

>
> > > Do I find this in the myPage.aspx ?
> > > This is what it says in myPage.aspx:
> > > <%@ Page Language="vb" AutoEventWireup="false"
> > > Inherits="Auction.WebForm1" CodeFile="myPage.aspx.vb" %>
> > > I do not define/change it, it is like that already. Does it mean that
> > > it is set to False ?

>
> > > > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > > How can I eliminate the Handles statement ?

>
> > > Thank you.

>
> > > On Apr 29, 7:16 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com>
> > > wrote:

>
> > > > Are you setting AutoEventWireup to true
> > > > (or are you not defining it, since by default it is true) ?

>
> > > > Page events are automatically bound to methods that use the naming convention of
> > > > Page_event, such asPage_Load, when you set AutoEventWireup to true or not set it to false.

>
> > > > If you set AutoEventWireup to true, and then use the Handles statement,
> > > > you will get Page eventscalledtwice, once by AutoEventWireup,
> > > > and again when you use Handles.

>
> > > > Test by setting AutoEventWireup to false, or by eliminating the Handles statement.

>
> > > > Juan T. Llibre, asp.net MVP
> > > > asp.net faq :http://asp.net.do/faq/
> > > > foros de asp.net, en espaņol :http://asp.net.do/foros/
> > > > ===================================
> > > <fiefie.ni...@gmail.com> wrote in message

>
> > > >news: roups.com...

>
> > > > >I am using ASP.NET 2005 and I have a simple form.Page_Loadcalls a
> > > > > sub mySub that does not do anything (for testing purposes). But,
> > > > >Page_Loadgetscalledtwice.
> > > > > On every single ASPX page in my site,Page_Loadgetscalledtwice. Why
> > > > > is that and how can I fix this problem ?
> > > > > Thank you very much.

>
> > > > > Imports System.IO
> > > > > Namespace myProject
> > > > > Partial Class WebForm1
> > > > > Inherits System.Web.UI.Page
> > > > > Protected WithEvents HyperLink1 As
> > > > > System.Web.UI.WebControls.HyperLink

>
> > > > > #Region " Web Form Designer Generated Code "
> > > > > 'This call is required by the Web Form Designer.
> > > > > <System.Diagnostics.DebuggerStepThrough()>
> > > > > Private Sub InitializeComponent()
> > > > > End Sub

>
> > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
> > > > > As System.EventArgs) Handles MyBase.Init
> > > > > 'CODEGEN: This method call is required by the Web Form
> > > > > Designer
> > > > > 'Do not modify it using the code editor.
> > > > > InitializeComponent()
> > > > > End Sub
> > > > > #End Region

>
> > > > > Protected SubPage_Load(ByVal sender As System.Object, ByVal e
> > > > > As System.EventArgs) Handles MyBase.Load, Me.Load
> > > > > mySub()
> > > > > End Sub
> > > > > Sub mySub()
> > > > > End Sub
> > > > > End Class
> > > > > End Namespace- Hide quoted text -

>
> > > > - Show quoted text -- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



 
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
Page_load called twice on button click Imran Aziz ASP .Net 6 09-06-2005 01:55 PM
Page_Load and Page_Init get called twice, sometimes! Dot net work ASP .Net 6 11-24-2004 08:04 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 called twice??? Andy ASP .Net 4 10-20-2003 09:00 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