473,573 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page_Load gets called twice

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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink

#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub

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

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

Apr 29 '07 #1
11 2685
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/
=============== =============== =====
<fi**********@g mail.comwrote in message
news:11******** **************@ c35g2000hsg.goo glegroups.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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink

#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub

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

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


Apr 30 '07 #2
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="Aucti on.WebForm1" CodeFile="myPag e.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.comwr ote in message

news:11******** **************@ c35g2000hsg.goo glegroups.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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load, Me.Load
mySub()
End Sub
Sub mySub()
End Sub
End Class
End Namespace- Hide quoted text -

- Show quoted text -

Apr 30 '07 #3
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.EventArg s) 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.EventArg s)


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/
=============== =============== =====
<fi**********@g mail.comwrote in message
news:11******** **************@ u30g2000hsc.goo glegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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.comwrote in message
>
news:11******** **************@ c35g2000hsg.goo glegroups.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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load, Me.Load
mySub()
End Sub
Sub mySub()
End Sub
End Class
End Namespace- Hide quoted text -

- Show quoted text -


Apr 30 '07 #4
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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles
MyBase.Load

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

Protected SubPage_Load(By Val sender As System.Object, ByVal e As System.EventArg s)

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.comwr ote in message

news:11******** **************@ u30g2000hsc.goo glegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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 Handlesstatemen t.

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 eventscalledtwi ce, once by AutoEventWireup ,
and again when you use Handles.
Test by setting AutoEventWireup to false, or by eliminating the Handlesstatemen t.
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.comwrote in message
news:11******** **************@ c35g2000hsg.goo glegroups.com.. .
>I am using ASP.NET 2005 and I have a simple form.Page_Loadc alls a
sub mySub that does not do anything (for testing purposes). But,
>Page_Loadgetsc alledtwice.
On every single ASPX page in my site,Page_Loadg etscalledtwice. 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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected SubPage_Load(By Val sender As System.Object, ByVal e
As System.EventArg s) 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 -

May 1 '07 #5
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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles
MyBase.Load

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

Protected SubPage_Load(By Val sender As System.Object, ByVal e As System.EventArg s)

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.comwr ote in message

news:11******** **************@ u30g2000hsc.goo glegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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 Handlesstatemen t.

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 eventscalledtwi ce, once by AutoEventWireup ,
and again when you use Handles.
Test by setting AutoEventWireup to false, or by eliminating the Handlesstatemen t.
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.comwrote in message
news:11******** **************@ c35g2000hsg.goo glegroups.com.. .
>I am using ASP.NET 2005 and I have a simple form.Page_Loadc alls a
sub mySub that does not do anything (for testing purposes). But,
>Page_Loadgetsc alledtwice.
On every single ASPX page in my site,Page_Loadg etscalledtwice. 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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected SubPage_Load(By Val sender As System.Object, ByVal e
As System.EventArg s) 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 -

May 1 '07 #6
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/
=============== =============== =====
<fi**********@g mail.comwrote in message
news:11******** ************@e6 5g2000hsc.googl egroups.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles
MyBase.Load

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

Protected SubPage_Load(By Val sender As System.Object, ByVal e As System.EventArg s)

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.comwr ote in message

news:11******** **************@ u30g2000hsc.goo glegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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 eventscalledtwi ce, 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.comwrote in message
news:11******** **************@ c35g2000hsg.goo glegroups.com.. .
>I am using ASP.NET 2005 and I have a simple form.Page_Loadc alls a
sub mySub that does not do anything (for testing purposes). But,
>Page_Loadgetsc alledtwice.
On every single ASPX page in my site,Page_Loadg etscalledtwice. 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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected SubPage_Load(By Val sender As System.Object, ByVal e
As System.EventArg s) 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 -


May 1 '07 #7
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 ...@gmail.comwr ote in message

news:11******** ************@e6 5g2000hsc.googl egroups.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 dois 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(By Val sender As System.Object, ByVal e As System..EventAr gs) Handles
MyBase.Load
If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :
Protected SubPage_Load(By Val sender As System.Object, ByVal e As System..EventAr gs)
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.comwr ote in message
news:11******** **************@ u30g2000hsc.goo glegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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 ornot set it to false.
If you set AutoEventWireup to true, and then use the Handles statement,
you will get Page eventscalledtwi ce, 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.comwrote in message
>news:11******* *************** @c35g2000hsg.go oglegroups.com. ..
I am using ASP.NET 2005 and I have a simple form.Page_Loadc alls a
sub mySub that does not do anything (for testing purposes). But,
Page_Loadgetsca lledtwice.
On every single ASPX page in my site,Page_Loadg etscalledtwice. 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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected SubPage_Load(By Val sender As System.Object, ByVal e
As System.EventArg s) 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 -

May 1 '07 #8
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/
=============== =============== =====
<fi**********@g mail.comwrote in message
news:11******** **************@ u30g2000hsc.goo glegroups.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 ...@gmail.comwr ote in message

news:11******** ************@e6 5g2000hsc.googl egroups.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles
MyBase.Load
If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :
Protected SubPage_Load(By Val sender As System.Object, ByVal e As System.EventArg s)
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.comwr ote in message
news:11******** **************@ u30g2000hsc.goo glegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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 eventscalledtwi ce, 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.comwrote in message
>news:11******* *************** @c35g2000hsg.go oglegroups.com. ..
I am using ASP.NET 2005 and I have a simple form.Page_Loadc alls a
sub mySub that does not do anything (for testing purposes). But,
Page_Loadgetsca lledtwice.
On every single ASPX page in my site,Page_Loadg etscalledtwice. 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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected SubPage_Load(By Val sender As System.Object, ByVal e
As System.EventArg s) 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 -


May 1 '07 #9
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_Loadtwic e?

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 ...@gmail.comwr ote in message

news:11******** **************@ u30g2000hsc.goo glegroups.com.. .
Thanks again.
Do you know if there is ever any need to call upPage_Loadtwic e?

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 ...@gmail.comwr ote in message
news:11******** ************@e6 5g2000hsc.googl egroups.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles
MyBase.Load
If you set AutoEventWireup to true, you wouldn't need the Handles method, and you could use :
Protected SubPage_Load(By Val sender As System.Object, ByVal e As System.EventArg s)
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.comwr ote in message
>news:11******* *************** @u30g2000hsc.go oglegroups.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="Aucti on.WebForm1" CodeFile="myPag e.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 eventscalledtwi ce, 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.comwrote in message
news:11******** **************@ c35g2000hsg.goo glegroups.com.. .
>I am using ASP.NET 2005 and I have a simple form.Page_Loadc alls a
sub mySub that does not do anything (for testing purposes). But,
>Page_Loadgetsc alledtwice.
On every single ASPX page in my site,Page_Loadg etscalledtwice. 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.P age
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()>
Private Sub InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVale
As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Protected SubPage_Load(By Val sender As System.Object, ByVal e
As System.EventArg s) 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 -

May 1 '07 #10

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

Similar topics

8
9551
by: Andy | last post by:
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!
1
4002
by: Jon | last post by:
Hi, I've set up a new web form (new.aspx) that inherits a BasePage class. The new web form contains an override Page_Load event. In BasePage, Page_Load is declared 'virtual'. In the new web form, base.Page_Load is called from within its Page_Load method so that both Page_Load methods are executed. AutoEventWireup is set to False, yet...
4
2985
by: Julia | last post by:
Hi Everyone, I am using webbrowser control to post data to an aspx page. However, for some reason, the aspx page sometimes will execute page_load event twice, and sometimes execute it once. So I might get different results for executing it. If I have the webbrwoser control to call it the first time, the aspx will usually execute the...
2
3185
by: Eric Maia | last post by:
I have a textbox (StartDateTextBox) in a UserControl on my page, that is supposed to have a date entered into it. I have a RequiredFieldValidator that has its ControlToValidate property set to the textbox. I also have a CompareValidator pointed to the textbox with its Type="Date." Despite all documentation to the contrary, I am getting an...
4
1709
by: Ed | last post by:
Has anyone seen this one? I have a situation where code in my page_load event is firing twice for mozilla firefox users. Everything is fine in IE6. I set breakpoints and verified. The second time the page_load fires in mozilla, I checked the IsPostback to verify that it is still false. What causes this behavior? Thanks, Ed
6
5967
by: Dot net work | last post by:
I've read quite a few threads on these groups about this. When someone says the following: "My Page_Load gets called twice on a button click postback" The replies are: "Do you have AutoEventWireup=True in your page header?" In my project, I have this set to false - everywhere.
3
8755
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called twice, once with postback true, and second time without postback. This only happens for this button. How can I sort out this issue, any clues what...
2
1286
by: Dave Hagerich | last post by:
I currently have an aspx page that contains a datagrid object and every time the page goes through its lifecycle the Page_Load event gets called twice. I've checked my code and I'm not manually calling it anywhere so the server must be doing it. Can anybody tell me why? and is it possible to stop it? Im using if(!IsPostBack) to see it its a...
1
6931
by: puja | last post by:
hi all, I have this .aspx page for which the Page_load event occurs twice. I found out while debugging. After searching google, I tried checking with Page.Ispostback method and also had "AutoEventWireUp" = false and also run after removing this tag from page directive but still my page_load event gets called twice. I have 3 pages called...
0
7765
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7681
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8000
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8054
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5578
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3729
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3729
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1294
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.