PostBackOptions.ActionUrl 属性

定义

获取或设置 Web 窗体页回发的目标 URL。Gets or sets the target URL for the postback of a Web Forms page.

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 窗体页回发的 URL。The URL for the postback of a Web Forms page. 默认值为空字符串 ("")。The default value is an empty string ("").

示例

下面的代码示例演示了在 ActionUrl PostBackOptions 用户将鼠标指针置于控件上时,如何使用对象的属性来导致跨页面回发 LabelThe following code example demonstrates using the ActionUrl property of a PostBackOptions object to cause a cross-page postback if a user positions the mouse pointer on a Label control.

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

注解

ActionUrl类的属性 PostBackOptions 指定 action Web 窗体页的属性的 URL。The ActionUrl property of the PostBackOptions class specifies the URL for the action attribute of a Web Forms page. ActionUrl属性可用于指定要将数据发回的 Web 窗体页,从而导致跨页面的 post。The ActionUrl property can be used to specify which Web Forms page to post data back to, causing a cross-page post. 有关跨页面发送的详细信息,请参阅 ASP.NET Web Forms 中的跨页面发布For more information on cross-page posting, see Cross-Page Posting in ASP.NET Web Forms.

适用于