ASP.Net/Page/Page Init — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:53, 26 мая 2010
Page Event: init (C#)
<%@ Page Language="C#" Debug="true"%>
<script runat="server">
void Page_Init()
{
Trace.Write("NOTE - First line of Page_Init");
}
</script>
<html>
<head>
<title>Demonstration of Page Events</title>
</head>
<body>
<form runat="server">
<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button>
<br />
</form>
</body>
</html>
Page init and load event (VB.net)
<script language="vb" runat="server">
Dim intGlobal As Integer = 0
Sub Page_Init()
intGlobal=intGlobal+1
Message1.Text += "<br>Page_Init has called this line at " & Now() & _
" with the value of intGlobal being :" & intGlobal
End Sub
Sub Page_Load()
intGlobal=intGlobal+1
Message2.Text += "<br>Page_Load has called this line at " & Now() & _
" with the value of intGlobal being :" & intGlobal
End Sub
</script>
<html>
<head>
<title>Automatic Events Example</title>
</head>
<body>
<form runat="server">
<input type="submit" value="Click to continue">
<br />
<asp:label id="message1" runat="server"/>
<asp:label id="message2" runat="server"/>
</form>
</body>
</html>