【www.gdgbn.com--安卓教程】

ASP.NET - Page_Load事件与Page.IsPostBack
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>



ASP.NET - Page_Load事件与Page.IsPostBack


Page.IsPostBack 属性
Page_Load 子例程会在页面每次加载时运行。如果您仅希望在页面第一次加载时执行 Page_Load 子例程中的代码,您可以使用 Page.IsPostBack 属性。如果 Page.IsPostBack 属性为 false,则页面第一次被载入,如果为 true,则页面传回服务器(例如,通过点击表单上的按钮):

Sub Page_Load
if Not Page.IsPostBack then
  lbl1.Text="The date and time is " & now()
end if
End Sub

Sub Submit(s As Object, e As EventArgs)
lbl2.Text="Hello World!"
End Sub


<asp教程:label id="lbl1" runat="server" />




Page_Load 事件


<script runat="server">
Sub Page_Load
lbl1.Text="The date and time is " & now()
End Sub
</script>

 



Page_Load 事件是众多 ASP.NET 可理解的事件之一。Page_Load 事件会在页面加载时被触发,然后 ASP.NET 会自动调用子例程 Page_Load

 

<%
lbl1.Text="The date and time is " & now()
%>




本文来源:http://www.gdgbn.com/shoujikaifa/24724/