小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Button.PostBackUrl 屬性

 趨明 2012-03-16

下面的代碼示例演示如何使用 PostBackUrl 屬性執(zhí)行跨頁面發(fā)送。 當用戶單擊 Button 控件時,頁面會將文本框中輸入的值發(fā)送到 PostBackUrl 屬性指定的目標頁。 若要運行此示例,您還必須在本代碼示例所在的目錄下創(chuàng)建目標頁文件。 目標頁的代碼將在下一個示例中提供。

 
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www./1999/xhtml" >
<head id="head1" runat="server">
  <title>Button.PostBackUrl Example</title>
</head>
<body>    
  <form id="form1" runat="server">

    <h3>Button.PostBackUrl Example</h3>

    Enter a value to post:
    <asp:textbox id="TextBox1" 
      runat="Server">
    </asp:textbox>

    <br /><br />

    <asp:button id="Button1" 
      text="Post back to this page"
      runat="Server">
    </asp:button>

    <br /><br />

    <asp:button id="Button2"
      text="Post value to another page" 
      postbackurl="Button.PostBackUrlPage2vb.aspx" 
      runat="Server">
    </asp:button>

  </form>
</body>
</html>


下面的代碼示例演示如何使用 Page.PreviousPage 屬性訪問使用 PostBackUrl 屬性從其他頁發(fā)送的值。 該頁獲取從上一頁發(fā)送的字符串,并將其顯示給用戶。 如果嘗試直接運行此代碼示例,則會發(fā)生錯誤,因為 text 字段的值將為 Nothing 正確的做法是使用此代碼創(chuàng)建一個目標頁,并將目標頁文件與上一示例的代碼放在同一目錄下。 目標頁文件名必須與上一示例中為 PostBackUrl 屬性指定的值相對應(yīng)。 當運行上一示例的代碼時,此頁將在發(fā)生跨頁面發(fā)送時自動執(zhí)行。

安全說明 安全說明

此示例有一個接受用戶輸入的文本框,這是一個潛在的安全威脅。 默認情況下,ASP.NET 網(wǎng)頁驗證用戶輸入是否不包含腳本或 HTML 元素。 有關(guān)更多信息,請參見腳本侵入概述。

 
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

    Dim text As String

    ' Get the value of TextBox1 from the page that posted
    ' to this page.
    text = CType((PreviousPage.FindControl("TextBox1")), TextBox).Text

    ' Check for an empty string.
    If Not (text = "") Then
      PostedLabel.Text = "The string posted from the previous page is " _
                         & text & "."
    Else
      PostedLabel.Text = "An empty string was posted from the previous page."
    End If

  End Sub

</script>

<html xmlns="http://www./1999/xhtml" >
<head id="head1" runat="server">
  <title>Button.PostBackUrl Target Page Example</title>
</head>
<body>
  <form id="form1" runat="server">

    <h3>Button.PostBackUrl Target Page Example</h3>

    <br />

    <asp:label id="PostedLabel"
       runat="Server">
    </asp:label>

    </form>
</body>
</html>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多