Page.EnableEventValidation Propriedade

Definição

Obtém ou define um valor que indica se a página valida eventos de postback e retorno de chamada.Gets or sets a value indicating whether the page validates postback and callback events.

public:
 virtual property bool EnableEventValidation { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public virtual bool EnableEventValidation { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.EnableEventValidation : bool with get, set
Public Overridable Property EnableEventValidation As Boolean

Valor da propriedade

Boolean

true se a página validar eventos de postback e de retorno de chamada; caso contrário, false .true if the page validates postback and callback events; otherwise, false. O padrão é true.The default is true.

Atributos

Exceções

A propriedade EnableEventValidation foi definida após a página ter sido inicializada.The EnableEventValidation property was set after the page was initialized.

Comentários

Quando a EnableEventValidation propriedade é definida como true , ASP.NET valida que um evento de controle foi originado da interface do usuário que foi renderizada por esse controle.When the EnableEventValidation property is set to true, ASP.NET validates that a control event originated from the user interface that was rendered by that control. Um controle registra seus eventos durante a renderização e, em seguida, valida os eventos durante o postback ou tratamento de retorno de chamada.A control registers its events during rendering and then validates the events during postback or callback handling. Por exemplo, se um controle de lista incluir opções numeradas 1, 2 ou 3 quando a página for renderizada, e se uma solicitação de postback for recebida especificando a opção número 4, ASP.NET gerará uma exceção.For example, if a list control includes options numbered 1, 2, or 3 when the page is rendered, and if a postback request is received specifying option number 4, ASP.NET raises an exception. Todos os controles controlados por eventos no ASP.NET usam esse recurso por padrão.All event-driven controls in ASP.NET use this feature by default.

Se você escrever um script de cliente que altere um controle no cliente em tempo de execução, talvez seja necessário usar o RegisterForEventValidation método para evitar erros falsos de validação de evento.If you write client script that changes a control in the client at run time, you might have to use the RegisterForEventValidation method in order to avoid false event validation errors.

Importante

Esse recurso reduz o risco de retornos de chamada e solicitações de postback não autorizados ou mal-intencionados.This feature reduces the risk of unauthorized or malicious postback requests and callbacks. É altamente recomendável que você não desabilite a validação de evento.It is strongly recommended that you do not disable event validation.

Defina a EnableEventValidation Propriedade definindo o enableEventValidation atributo da diretiva @ Page ou o enableEventValidation atributo do elemento pages no arquivo Web.config.You set the EnableEventValidation property by setting the enableEventValidation attribute of the @ Page directive or the enableEventValidation attribute of the pages element in the Web.config file. Se você definir essa propriedade no código, deverá defini-la antes que a página seja inicializada.If you set this property in code, you must set it before the page is initialized.

Aplica-se a

Confira também