Re: Page_Load gets called twice
- From: "Juan T. Llibre" <nomailreplies@xxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 20:16:05 -0400
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.niles@xxxxxxxxx> wrote in message
news:1177889150.489830.170860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
.
- Follow-Ups:
- Re: Page_Load gets called twice
- From: fiefie . niles
- Re: Page_Load gets called twice
- References:
- Page_Load gets called twice
- From: fiefie . niles
- Page_Load gets called twice
- Prev by Date: MailSettings code generates VS2005 error in web.config
- Next by Date: Re: MailSettings code generates VS2005 error in web.config
- Previous by thread: Page_Load gets called twice
- Next by thread: Re: Page_Load gets called twice
- Index(es):
Relevant Pages
|