Page.ViewStateEncryptionMode Page.ViewStateEncryptionMode Page.ViewStateEncryptionMode Page.ViewStateEncryptionMode Property

Definition

Gets or sets the encryption mode of the view state.

public:
 property System::Web::UI::ViewStateEncryptionMode ViewStateEncryptionMode { System::Web::UI::ViewStateEncryptionMode get(); void set(System::Web::UI::ViewStateEncryptionMode value); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.ViewStateEncryptionMode ViewStateEncryptionMode { get; set; }
member this.ViewStateEncryptionMode : System.Web.UI.ViewStateEncryptionMode with get, set
Public Property ViewStateEncryptionMode As ViewStateEncryptionMode

Property Value

Exceptions

The ViewStateEncryptionMode property can be set only in or before the page PreRender phase in the page life cycle.

Remarks

The ViewStateEncryptionMode property cannot be set in code. It can only be set in the @ Page directive or in the < element of the configuration file. Values set in the @ Page directive override any values set in the configuration file.

The syntax for setting this property in the @ Page directive is as follows:

<%@ Page Language="VB" ViewStateEncryptionMode="Always" %>  
<%@ Page Language="C#" ViewStateEncryptionMode="Always" %>  

The syntax for setting this property in the configuration file is as follows:

<system.web>  
  <pages viewStateEncryptionMode="Always" />  
</system.web>  
<system.web>  
  <pages viewStateEncryptionMode="Always" />  
</system.web>  

Custom control developers may wish to check the value of this property in code before saving potentially sensitive data to view state in their control.

Applies to

See also