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

Updated: October 2009

Gets or sets a value indicating whether the page validates postback and callback events.

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

Visual Basic (Declaration)
<BrowsableAttribute(False)> _
Public Overridable Property EnableEventValidation As Boolean
Visual Basic (Usage)
Dim instance As Page
Dim value As Boolean

value = instance.EnableEventValidation

instance.EnableEventValidation = value
C#
[BrowsableAttribute(false)]
public virtual bool EnableEventValidation { get; set; }
Visual C++
[BrowsableAttribute(false)]
public:
virtual property bool EnableEventValidation {
    bool get ();
    void set (bool value);
}
JScript
public function get EnableEventValidation () : boolean
public function set EnableEventValidation (value : boolean)
ASP.NET
<asp:Page EnableEventValidation="True|False" />

Property Value

Type: System..::.Boolean
true if the page validates events; otherwise, false.The default is true.
Exceptions

ExceptionCondition
InvalidOperationException

The EnableEventValidation property was set after the page was initialized.

Remarks

The event validation mechanism reduces the risk of unauthorized postback requests and callbacks. When the EnableEventValidation property is set to true, ASP.NET allows only the events that can be raised by the control during a postback request or callback.

NoteNote:

This event validation mechanism reduces the risk of unauthorized postback requests and callbacks. 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.

It is strongly recommended that you do not disable event validation. If you do disable event validation, make sure that no postback could be constructed that could have an unintended effect on your application.

You set the EnableEventValidation property by setting the enabledEventValidation attribute of the @ Page directive or the enableEventValidation attribute of the pages element in the Web.config file. You cannot set the EnableEventValidation property in code.

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

Other Resources

Change History

Date

History

Reason

October 2009

Corrected text that indicated the property could be set in code.

Content bug fix.

Tags :


Community Content

Tom Dykstra - MSFT
Documentation is wrong, Page_Init and OnInit is not possible
You cannot set the EnableEventValidation in the PageInit phase. If you do so, you will it will throw InvalidOperationException.

[tdykstra]The EnableEventValidation property can only be set in the page directive or in the <pages> configuration section.
Tags : cpubfix

Page view tracker