Page_Load

A

A.M

Hi,

Why in the following page, word ABC is being appear twice?

Thanks,
Ali

<%@ Page %>
<HTML>
<HEAD>
<title>test</title>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Me.IsPostback Then
Response.Write("ABC" + "<br>" )
end if
End Sub
</script>
</HTML>
 
S

Steven Cheng[MSFT]

Hi Ali,


Thank you for posting here. I find this post is a duplicated one with
another twos in the queue:
Subject: Page_Load

This is the second one you posted. Also, another MS support FelixWu[MSFT]
has replied you in the first one, I'm not sure whether you are able to see
the reply correctly? If not here is the reply's weblink in google:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=nsDtQix6
DHA.3496%40cpmsftngxa07.phx.gbl&rnum=36&prev=/groups%3Fq%3DPage_Load%26hl%3D
en%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D30%26sa%3DN


Also, here is the original content of FelixWu[MSFT]'s reply, you may check
it if you event unable to visit its weblink in google:

----------------------------------reply
content--------------------------------------------
From: (e-mail address removed) (Felix Wu [MSFT])
Date: Wed, 04 Feb 2004 12:15:12 GMT
Subject: RE: Page_Load
Newsgroups: microsoft.public.dotnet.framework.aspnet

Hi A.M,

You do not need to explicitly register the event handler Page_Load to the
Load event because it is registered by default:

<%@ Page %>
<HTML>
<HEAD>
<title>test</title>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If Not Me.IsPostback Then
Response.Write("ABC" + "<br>" )
end if
End Sub
</script>
</HTML>

Actually, this behavior is controlled by the AutoEventWireup attribute in @
Page directive. This attribute indicates whether the page's events are
autowired. "true" if event autowiring is enabled; otherwise, false. The
default is true. If you disable it, "ABC" only is displayed once:

<%@ Page AutoEventWireup=False%>
<HTML>
<HEAD>
<title>test</title>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Me.IsPostback Then
Response.Write("ABC" + "<br>" )
end if
End Sub
</script>
</HTML>

Regards,

Felix Wu
----------------------------------------------------------------------------
--------------------

If you have any other questions or need any assistance, please feel free to
post here.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top