Please visit our sponsors !
ASP.NET - Events
Event Handlers ensures that code is executed at the right time.
ASP.NET - Event Handlers
This code was explained in the previous chapter:
<%
TimeStamp.Text=now()
%>
<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3Schools!</h2>
<asp:label id="TimeStamp" runat="server" />
</center>
</body>
</html> |
How can you know when the code (the render block in red) will be executed?
The answer to that question is: "You don't know"
To make the code more understandable, and to ensure that
code will be executed at the right time we have added an Event Handler:
<script runat="server">
Sub Page_Load(Sender As Object,E As EventArgs)
TimeStamp.Text=now()
End Sub
</script>
<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3Schools!</h2>
<asp:label id="TimeStamp" runat="server" />
</center>
</body>
</html> |
An Event Handler is a subroutine that executes code for a given event.
The event Page_Load is one of many events that ASP.NET understands. When a
page loads, ASP.NET calls the subroutine Page_Load, and executes the code inside
it.
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|