Page.RaisePostBackEvent(IPostBackEventHandler, String) Method

Definition

Notifies the server control that caused the postback that it should handle an incoming postback event.

C#
protected virtual void RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl, string eventArgument);

Parameters

sourceControl
IPostBackEventHandler

The ASP.NET server control that caused the postback. This control must implement the IPostBackEventHandler interface.

eventArgument
String

The postback argument.

Examples

The following example uses the RaisePostBackEvent method to notify ASP.NET that a post-back event is raised when a custom userButton server control is clicked.

C#
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);
}

Remarks

The Page object calls the RaisePostBackEvent method when a postback occurs. This call occurs in the page life cycle after loading and change notification are complete but before prerendering occurs.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also