Page.RegisterRequiresRaiseEvent(IPostBackEventHandler) Page.RegisterRequiresRaiseEvent(IPostBackEventHandler) Page.RegisterRequiresRaiseEvent(IPostBackEventHandler) Page.RegisterRequiresRaiseEvent(IPostBackEventHandler) Method

Definición

Registra un control de servidor ASP.NET como control que requiere que se provoque un evento cuando se procese en el objeto Page.Registers an ASP.NET server control as one requiring an event to be raised when the control is processed on the Page object.

public:
 virtual void RegisterRequiresRaiseEvent(System::Web::UI::IPostBackEventHandler ^ control);
public virtual void RegisterRequiresRaiseEvent (System.Web.UI.IPostBackEventHandler control);
abstract member RegisterRequiresRaiseEvent : System.Web.UI.IPostBackEventHandler -> unit
override this.RegisterRequiresRaiseEvent : System.Web.UI.IPostBackEventHandler -> unit
Public Overridable Sub RegisterRequiresRaiseEvent (control As IPostBackEventHandler)

Parámetros

control
IPostBackEventHandler IPostBackEventHandler IPostBackEventHandler IPostBackEventHandler

Control que se va a registrar.The control to register.

Ejemplos

En el ejemplo de código siguiente RegisterRequiresRaiseEvent se usa el método Button para registrar un control de servidor Web que requiere que se genere un evento.The following code example uses the RegisterRequiresRaiseEvent method to register a Button Web server control as requiring an event to be raised. Después de haber registrado el primer Button control, puede hacer que el segundo Button control declarado en el código publique los resultados del evento click del primer botón en la página.After you have registered the first Button control, you can cause the second Button control declared in the code to post the results of the first button's click event to the page.

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

Comentarios

Solo se puede registrar un control de servidor por solicitud de página.Only one server control can be registered per page request. Se RegisterRequiresRaiseEvent debe usar cuando el control no incluya su identificador de control en los datos de envío del formulario.The RegisterRequiresRaiseEvent must be used when the control does not include its control ID in the form post data. Además, el control que se registra debe implementar la IPostBackEventHandler interfaz.Also, the control that is registered must implement the IPostBackEventHandler interface.

Se aplica a

Consulte también: