iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning ASP-NET Course: ASP.NET Event Handler - www.itechcollege.com ASP-NET Course: ASP.NET Event Handler - www.itechcollege.com
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
C++
ASP.NET
SQL
AJAX
FTP
XML

courses > ASP-NET > ASP.NET Event Handler

ASP.NET Event Handler

An Event Handler is to execute code for a given event. The Page_Load event is triggered when a page loads. For example:

<script runat="server">
Sub Page_Load
lbl1.Text="Free online courses from iTechCollege.com"
End Sub
</script>

<html>
<body>
<form runat="server">
<p><asp:label id="lbl1" runat="server" /></p>
</form>
</body>
</html>

In the above example, the Page_Load subroutine runs every time when the page is loaded. If you want the Page_Load subroutine is only executed at the first time the page is loaded, you can use the Page.IsPostBack property. If the Page.IsPostBack property is false, the page is loaded for the first time, if it is true, the page is posted back to the server. See the following example:

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
lbl1.Text="Best GPS Store - www.SelectaGPS.com"
end if
End Sub

Sub submit(s As Object, e As EventArgs)
lbl2.Text="Buy wireless devices from iShopSale.com"
End Sub
</script>

<html>
<body>
<form runat="server">
<p><asp:label id="lbl1" runat="server" /></p>
<p><asp:label id="lbl2" runat="server" /></p>
<asp:button text="Submit" onclick="submit" runat="server" />
</form>
</body>
</html>

As you can see, the example above will write the "Buy wireless devices from iShopSale.com" message only the first time the page is loaded. When a user clicks on the Submit button, the submit subroutine will write "Best GPS Store - www.SelectaGPS.com".



  Back to Index Page
 Next Page:  

Introduction
Server Controls
Event Handler
Web Forms
Database Connection


Online Education, Online Training for Your Job, Distance Education, E-learning Programs for Your Career!Online Colleges, Online Universities, E-learning & Distance Education for Your Career! Easy Job Training & Online Courses.


   Email A Friend  
 
Earn Online Degree
for Your Job
I found a job after I earned an online degree!
Online classes for finding a Job. Online College, Online University, Degrees, E-learning school, online certificate Earn your
online degree now!
Online Training
for Good Job
Why I work so hard but earn so little? Why I cannot find a high paying job?
Online training for a Good Jobs. Online Degree, E-learning school, online certificate Go to
online school now!

Copyright ©2024, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech