Page.RaisePostBackEvent(IPostBackEventHandler, String) Metoda

Definicja

Powiadamia kontrolkę serwera, która spowodowała powiadomienie zwrotne, że powinno obsługiwać przychodzące zdarzenie ogłaszania zwrotnego.

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)

Parametry

sourceControl
IPostBackEventHandler

Kontrola serwera ASP.NET, która spowodowała powrót po awarii. Ta kontrolka IPostBackEventHandler musi implementować interfejs.

eventArgument
String

Argument ogłaszania zwrotnego.

Przykłady

W poniższym przykładzie użyto RaisePostBackEvent metody , aby powiadomić ASP.NET, że po kliknięciu niestandardowego userButton formantu serwera zostanie zgłoszone zdarzenie po powrocie.

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

Uwagi

Obiekt Page wywołuje metodę po wystąpieniu RaisePostBackEvent ogłaszania zwrotnego. To wywołanie odbywa się w cyklu życia strony po załadowaniu i zakończeniu powiadamiania o zmianie, ale przed rozpoczęciem obsługi wstępnej.

Dotyczy

Zobacz też