ASP.Net/Page/Postback
Содержание
Demonstration of IsPostBack property (VB.net)
<source lang="csharp">
<% @Page Language="vb" %> <html> <head> <title>IsPostBack Demonstration</title> <script runat="server" >
Sub Page_Load(Sender As Object, e As EventArgs) If Not IsPostBack Then lblMessage.Text = "Before PostBack" Else lblMessage.Text = "Posted Back" End If End Sub
</script> </head> <body>
Demonstration of IsPostBack property
<form id="frmPostBack" runat="server"> <asp:label id="lblMessage" runat="server"/> <asp:Button type="Submit" text="Post Back" runat="server"/> </form>
</body> </html>
</source>
Page IsPostBack Demo (C#)
<source lang="csharp">
<%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(){
if (Page.IsPostBack){ string[] choice = new string[3]; choice[0] = "1"; choice[1] = "2"; choice[2] = "3"; lblShipper.Text = "Shipper ID for " + txtShipNum.Text + " is " + Array.IndexOf(choice, txtShipNum.Text); lblShipper.Visible = true; }
} </script> <html> <head>
<title>Array Example</title>
</head> <body>
<form runat="server"> Please enter your shipper name. (should be "1" or "2" or "3")
<asp:TextBox id="txtShipNum" runat="server" width="300px"></asp:TextBox>
Press button to find the Shipper ID number <asp:Button id="Button1" runat="server" Text="Submit"></asp:Button>
<asp:Label id="lblShipper" runat="server"></asp:Label> </form>
</body> </html>
</source>
Page.IsPostBack Property (VB.net)
<source lang="csharp">
<%@ Page Language="vb" %> <html>
<head> <title>IsPostBack property example</title> <script runat="server"> Sub Page_Load() If Page.IsPostBack Then Message.Text = "PostBack" Else Message.Text = "Non-PostBack" End If End Sub </script> </head>
<body>
<form runat="server"> <asp:button id="post" Text="Post page" runat="server"/> <asp:label id="Message" runat="server"/> </form>
</body> </html>
</source>