Page events
Previously, I mentioned that ASP. NET has been rewritten from scratch, but I did not point out that it was rebuilt based on the object-oriented approach. At the top of the Object Tree is a Page object, that is, a Page object, ASP. NET, each control, application, and page are inherited from this object, that is, each page is an example of a page object. The page Load event is a very important event, as shown in table 3 code below:
Table 3 Use Page events
<Html>
<Script language = "VB" runat = "server">
Sub Page_Load (Source As Object, E As EventArgs)
'Code to run when page loads
End Sub
Sub SubmitButton_Click (Source As Object, E As EventArgs)
'Code to run when button is clicked
End Sub
Sub Page_Unload (Source As Object, E As EventArgs)
'Code to run when page unloads
End Sub
</Script>
<Form runat = "server">
<Asp: Button text = "Enter" OnClick = "SubmitButton_Click" runat = "server"/>
<Asp: label id = "YouEntered"/>
</Form>
</Html>
Here you see the same Load/Unload (Load/Unload) process often seen in Visual Basic. When a page is loaded, the Load event is activated, and all server-based controls are available. Other events are generated during interaction with users. Finally, the Unload event is activated when the page is uninstalled.