Back to Devexpress

ASPxFileManager.JSProperties Property

aspnet-devexpress-dot-web-dot-aspxfilemanager-a1b4628e.md

latest3.2 KB
Original Source

ASPxFileManager.JSProperties Property

Enables you to supply any server data that can then be parsed on the client.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public Dictionary<string, object> JSProperties { get; }
vb
Public ReadOnly Property JSProperties As Dictionary(Of String, Object)

Property Value

TypeDescription
Dictionary<String, Object>

The collection of property names and their values.

|

Remarks

In some instances, it is necessary to obtain server information on the client. The JSProperties property enables you to declare temporary client properties. The JSProperties property represents a collection of property names and their values. Once declared, a property can be accessed on the client.

Note

The only requirement is that property names must begin with the ‘cp’ prefix, to avoid rewriting the ASPxFileManager‘s base properties.

Example

The code below demonstrates how you can show information about folder contents in a label.

csharp
public string ItemsNumberToString(int count, string item) {
        if (count != 1) item = item + "s";
        return count.ToString() + " " + item;
}
protected void ASPxFileManager1_Load(object sender, EventArgs e) {
        int FileCount = ASPxFileManager1.SelectedFolder.GetFiles().Length;
        int FolderCount = ASPxFileManager1.SelectedFolder.GetFolders().Length;
        ASPxFileManager1.JSProperties["cpLabelText"] = "The " + ASPxFileManager1.SelectedFolder.Name + " folder contains " + ItemsNumberToString(FolderCount, "folder") + " and " + ItemsNumberToString(FileCount, "file");
}
aspx
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server" ClientInstanceName="fileManager" OnLoad="ASPxFileManager1_Load">
            <Settings RootFolder="~\" ThumbnailFolder="~\Thumb\" />
            <ClientSideEvents EndCallback="function(s, e) {label.SetText(fileManager.cpLabelText);}" />
</dx:ASPxFileManager>

<dx:ASPxLabel ID="ASPxLabel1" runat="server" ClientInstanceName="label">
</dx:ASPxLabel>

See Also

CustomJSProperties

Passing Values from the Server to the Client

File Manager

Callbacks

ASPxFileManager Class

ASPxFileManager Members

DevExpress.Web Namespace