[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Collapse]Common Concepts
  [Expand]Web.config Modifications
  [Expand]Callback Exception Handling
  [Collapse]Client-Side Functionality
    Client-Side Functionality Overview
    Client-Side API Availability for a Web Control
    Client-Side Events
   [Collapse]Passing Values Between Client and Server Sides
     How to Access Server Data on the Client Side
     List of Controls with the JSProperties and CustomJSProperties Members
    How to Register JavaScript on DevExpress Callbacks
    IntelliSense for Client API
  [Expand]Cookies Support
  [Expand]Appearance Customization - Theming
   Icon Collection
  [Expand]Performance Optimization
  [Expand]CSS Image Sprites
   Data Annotation Attributes
   Supported Document Types
  [Expand]Accessibility Support
   Right to Left Support
   HTML Encoding
  [Expand]SharePoint Support
   Mobile Support
  [Expand]Office Document Management
   Cloud Storage Account Management
  [Expand]Web Farm and Web Garden Support
 [Expand]ASP.NET WebForms Controls
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to Access Server Data on the Client Side

DevExpress ASP.NET controls provide two special members that allow you to pass data from the server side to the client side: the JSProperties Property and the CustomJSProperties Event (see the List of Controls with the JSProperties and CustomJSProperties Members topic).

These members allow you to pass a collection of name/value pairs form the server side to the client side (but not vice versa). The only requirement is that property names must begin with the 'cp' prefix, to avoid rewriting a control's base properties. The supported value types are listed below:

  • null
  • DBNull
  • ValueType
  • string
  • IDictionary
  • IEnumerable

Expanded JSProperties Property

The JSProperties property represents a collection of property names and their values, enabling you to declare temporary client properties. A property can be accessed on the client once it is declared.

Declaration

Example 1

Note

The complete sample project is available in the DevExpress Code Central database at http://www.devexpress.com/example=E4126. Depending on the target platform type (ASP.NET, WinForms, etc), you can either run this example online or download an auto-executable sample.

This example demonstrates how you can perform server-side actions when a user clicks the "Delete" command button, and then show the Delete confirmation PopupControl.

Example 2

How to send a JSON object to the client using the JSProperties property

Since a JSON object has a text format, you can use the JSProperties property ( or CustomJSProperties event) to send it as a string to the client side. Then, you can parse the string to get the object.

Expanded CustomJSProperties Event

The CustomJSProperties event fires each time a control callback or page postback is sent to the server side. The event enables you to declare temporary client properties using the event parameter's CustomJSPropertiesEventArgs.Properties property, which is a collection of property names and their values. A property can be accessed on the client after it has been declared.

Note

In most cases, it is more efficient to use the JSProperties property rather than handle the CustomJSProperties event, which is primarily declared for backwards compatibility.

Example

WebForms:

MVC:

Online Examples

Online Demo

Expanded See Also

Is this topic helpful?​​​​​​​