ポストバック@ASP.Net
ポストバックは、入力フォームなどにデータを入れて送信する際、現在のページに対して送信し、処理することを言います。
ポストバック時に、処理を行いたい/行いたくない時は、IsPostBackプロパティを利用します。
●aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ポストバック</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
|
●vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Me.Label1.Text = "PostBack"
Else
Me.Label1.Text = "PageLoad"
End If
End Sub
End Class
|