Share via


PostBackOptions.ActionUrl 屬性

定義

取得或設定 Web Form 網頁回傳的目標 URL。

public:
 property System::String ^ ActionUrl { System::String ^ get(); void set(System::String ^ value); };
public string ActionUrl { get; set; }
member this.ActionUrl : string with get, set
Public Property ActionUrl As String

屬性值

String

Web Form 網頁回傳的 URL。 預設值為空字串 ("")。

範例

下列程式碼範例示範如何使用 ActionUrl 物件的 屬性 PostBackOptions ,在使用者將滑鼠指標放在控制項上 Label 時,造成跨頁回傳。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  void Page_Init(object sender, EventArgs e)
  {
    
    string reference = Page.ClientScript.GetPostBackEventReference
      (new PostBackOptions(this, "", "http://www.wingtiptoys.com", false, true, false, true, false, ""));
    Label1.Attributes.Add("onmouseover", reference);
    
  } 

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ActionUrl Example Page</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <h3>PostBackOptions ActionUrl Example</h3>
      <asp:Label runat="server" 
        id="Label1" >
        Placing the mouse pointer on this label will cause a cross-page post to occur.
      </asp:Label>
    </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  
  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
    
    Dim reference As String = Page.ClientScript.GetPostBackEventReference _
      (New PostBackOptions(Me, "", "http://www.wingtiptoys.com", False, True, False, True, False, ""))
    Label1.Attributes.Add("onmouseover", reference)
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>ActionUrl Example Page</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <h3>PostBackOptions ActionUrl Example</h3>
      <asp:Label runat="server" 
        id="Label1" >
        Placing the mouse pointer on this label will cause a cross-page post to occur.
      </asp:Label>
    </form>
  </body>
</html>

備註

類別 ActionUrlPostBackOptions 屬性會指定Web Form頁面屬性的 URL action 。 屬性 ActionUrl 可用來指定要將資料張貼回哪個Web Form頁面,導致跨頁面張貼。 如需跨頁面張貼的詳細資訊,請參閱跨頁面張貼 ASP.NET Web Forms

適用於

另請參閱