Page.RaisePostBackEvent(IPostBackEventHandler, String) 方法

定义

通知引起回发的服务器控件:它应处理传入的回发事件。

protected:
 virtual void RaisePostBackEvent(System::Web::UI::IPostBackEventHandler ^ sourceControl, System::String ^ eventArgument);
protected virtual void RaisePostBackEvent (System.Web.UI.IPostBackEventHandler sourceControl, string eventArgument);
abstract member RaisePostBackEvent : System.Web.UI.IPostBackEventHandler * string -> unit
override this.RaisePostBackEvent : System.Web.UI.IPostBackEventHandler * string -> unit
Protected Overridable Sub RaisePostBackEvent (sourceControl As IPostBackEventHandler, eventArgument As String)

参数

sourceControl
IPostBackEventHandler

引起回发的 ASP.NET 服务器控件。 该控件必须实现 IPostBackEventHandler 接口。

eventArgument
String

回发参数。

示例

以下示例使用 RaisePostBackEvent 方法通知 ASP.NET 单击自定义 userButton 服务器控件时引发回发事件。

void DisplayUserName(Object sender, EventArgs ea) 
{
   Response.Write("Welcome to " + Server.HtmlEncode(userName.Text));
}
void RaiseEvent(Object sender, EventArgs ea)
{
   // Raise a post back event for a control.
   this.RaisePostBackEvent(userButton, "");
}
void Page_Load(Object sender, EventArgs ea)
{
   // Register a control as one that requires postback handling.
   this.RegisterRequiresRaiseEvent(userButton);
}
    Sub DisplayUserName(Sender As Object, e As EventArgs) 
       Response.Write("Welcome to " + Server.HtmlEncode(userName.Text))
    End Sub

   Sub MyRaiseEvent(Sender As Object, e As EventArgs)
       'Raises a post back event for a control.
        Me.RaisePostBackEvent(userButton, "")
   End Sub 
    
    Sub Page_Load(Sender As Object, e As EventArgs)

      'Registers a control as one that requires postback handling
      Me.RegisterRequiresRaiseEvent(userButton)
  End Sub

注解

发生 Page 回发时, RaisePostBackEvent 对象会调用 方法。 此调用在加载和更改通知完成后但在预呈现之前的页面生命周期中发生。

适用于

另请参阅