ASP. NET getting started Tutorial: Event handle, asp.net getting started tutorial
Event handler is a subroutine used to execute code for a given event.
ASP. NET-event handle
See the following code:
<%lbl1.Text="The date and time is " & now()%>
When will the above Code be executed? The answer is: "I don't know..." this article is for webpage teaching www.webjx.com to collect and organize or original content. For reprinting, please indicate the source!
Page_Load event
Page_Load is one of the many events that ASP. NET can understand. The Page_Load event is triggered when the page is loaded. ASP. NET automatically calls the child routine Page_Load and runs the Code:
<script runat="server">Sub Page_Loadlbl1.Text="The date and time is " & now()End Sub</script>
Note: This Page_Load event does not contain object references or event parameters!
Page. IsPostBack attributes
The Page_Load subroutine runs each time the page is loaded. If you only want to execute code in the Page_Load subroutine when the Page is loaded for the first time, you can use the Page. IsPostBack attribute. If the Page. IsPostBack attribute is false, the Page is loaded for the first time. If it is true, the Page is returned to the server (for example, by clicking the button on the form ):
<script runat="server">Sub Page_Loadif Not Page.IsPostBack then lbl1.Text="The date and time is " & now()end ifEnd SubSub Submit(s As Object, e As EventArgs)lbl2.Text="Hello World!"End Sub</script>
The preceding example only creates The message "The date and time is..." When The page is loaded for The first time. When you click the Submit button, the submit subroutine creates "Hello World!" in the second label! ", But the date and time in the first label will not change.
Reprinted from: http://www.aspnetjia.com/Cont-1145.html