ASPxClientUtils.GetCookie(name) Method
Retrieves a cookie with the specified name.
Declaration
static GetCookie(
name: string
): string
Parameters
Name | Type | Description |
---|---|---|
name | string | A string value that represents the name of a cookie. |
Returns
Type | Description |
---|---|
string | A string value, if the cookie exists. |
Example
This example demonstrates how to operate with cookies on the client, using the client ASPxClientUtils.SetCookie, ASPxClientUtils.GetCookie
and ASPxClientUtils.DeleteCookie methods of the ASPxClientUtils object.
function OnSelectedColorChanged(s, e) {
var color = s.GetSelectedItem().value;
document.body.style.backgroundColor = color;
ASPxClientUtils.SetCookie("backgroundColor", color);
}
function OnColorComboBoxInit(s, e) {
var color = ASPxClientUtils.GetCookie("backgroundColor");
document.body.style.backgroundColor = color;
if(color != null)
s.SetValue(color);
}
protected void Page_Load(object sender, EventArgs e) {
ASPxWebControl.RegisterUtilsScript(this);
}
<dx:ASPxComboBox id="cbColor" runat="server" SelectedIndex="0" ValueType="System.String">
<items>
<dx:ListEditItem Text="None" Value="" />
<dx:ListEditItem Text="Lavender" Value="Lavender" />
<dx:ListEditItem Text="Light Yellow" Value="LightYellow" />
<dx:ListEditItem Text="Light Green" Value="LightGreen" />
</items>
<clientsideevents init="OnColorComboBoxInit" selectedindexchanged="OnSelectedColorChanged" />
</dx:ASPxComboBox>
See Also