日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Button.PostBackUrl 屬性

 趨明 2012-03-16

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

 
<%@ 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ā)送的字符串,并將其顯示給用戶。 如果嘗試直接運(yùn)行此代碼示例,則會(huì)發(fā)生錯(cuò)誤,因?yàn)?text 字段的值將為 Nothing 正確的做法是使用此代碼創(chuàng)建一個(gè)目標(biāo)頁,并將目標(biāo)頁文件與上一示例的代碼放在同一目錄下。 目標(biāo)頁文件名必須與上一示例中為 PostBackUrl 屬性指定的值相對(duì)應(yīng)。 當(dāng)運(yùn)行上一示例的代碼時(shí),此頁將在發(fā)生跨頁面發(fā)送時(shí)自動(dòng)執(zhí)行。

安全說明 安全說明

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

 
<%@ 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>

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

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多