This documentation is archived and is not being maintained.

CookieParameter Class

Updated: July 2008

Binds the value of a client-side HTTP cookie to a parameter object. The parameter can be used in a parameterized query or command to select, filter, or update data.

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

[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class CookieParameter : public Parameter

You can use the CookieParameter class to bind the value of a client-side HTTP cookie passed as part of an HTTP request to a parameter used by ASP.NET data source controls.

The CookieParameter class provides the CookieName property, which identifies the name of the HttpCookie object to bind to, in addition to those inherited from the Parameter class. The CookieParameter class attempts to bind to the named cookie every time the Evaluate method is called.

Important noteImportant Note:

Controls that bind data to the parameter might throw an exception if a CookieParameter object is specified, but no corresponding cookie is passed with the HTTP request. Similarly, they might display no data if the cookie is passed with nullptr. Set the DefaultValue property to avoid these situations where appropriate.

The following code example demonstrates how to use a SqlDataSource control and CookieParameter object bound to an HTTP cookie to display data from the Northwind Traders database in a GridView control.

No code example is currently available or this language may not be supported.

System::Object
  System.Web.UI.WebControls::Parameter
    System.Web.UI.WebControls::CookieParameter

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Date

History

Reason

July 2008

Added new member: CookieParameter::CookieParameter

SP1 feature change.

Show: