.NET Framework Class Library
PagesSection..::.EnableEventValidation Property

Gets or sets a value that specifies whether event validation is enabled.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)
Syntax

Visual Basic (Declaration)
<ConfigurationPropertyAttribute("enableEventValidation", DefaultValue := True)> _
Public Property EnableEventValidation As Boolean
Visual Basic (Usage)
Dim instance As PagesSection
Dim value As Boolean

value = instance.EnableEventValidation

instance.EnableEventValidation = value
C#
[ConfigurationPropertyAttribute("enableEventValidation", DefaultValue = true)]
public bool EnableEventValidation { get; set; }
Visual C++
[ConfigurationPropertyAttribute(L"enableEventValidation", DefaultValue = true)]
public:
property bool EnableEventValidation {
    bool get ();
    void set (bool value);
}
JScript
public function get EnableEventValidation () : boolean
public function set EnableEventValidation (value : boolean)

Property Value

Type: System..::.Boolean
true if event validation is enabled; otherwise, false.
Remarks

The EnableEventValidation attribute indicates whether event validation should be performed. The default value is true. A Web application can optionally disable event validation to revert to .NET Framework version 1.0 behavior.

The base control checks this attribute to determine whether it should validate events. A derived control does not inherit this base control attribute, and so it is exempt from event validation by default. You still instruct ASP.NET to perform event validation on the derived control by adding the EnableEventValidation attribute to the derived control itself and setting it to true.

NoteNote:

Event validation reduces the risk of unauthorized postback requests and callbacks. It instructs ASP.NET to validate only those events that can be raised in the control during a postback request or callback. With this model, a control registers its events during rendering and then validates the events during the post-back or callback handling. All event-driven controls in ASP.NET use this feature by default.

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Tags :


Community Content

John P Thompson
This feature breaks some ASP.Net controls.

It should be noted that some people have experienced problems with various controls causing the following error:-

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

For example, here are two types of button control on the same form. The ImageButton errors when clicked on (see error message above), but the LinkButton executes correctly:-

<asp:ImageButton

ID="MyImageButton"

runat="server"

ImageUrl="~/Images/MyImage.gif"

OnClick="btnButton_Click"

CommandName="MyCommand"/>

and

<asp:LinkButton

ID="MyLinkButton"

runat="server"

text="test"

OnClick="btnButton_Click"

CommandName="MyCommand"/>

N.B. Before you ask, the event handler looks like this (so it can handle either type of control):-

protectedvoid btnButton_Click(object source, EventArgs e)

{

}

Looks like MS cut some corners testing Event Validation.


Page view tracker