AI & Machine Learning

storage_size.js Module in WebForms Core

59 sec read13 views0 listens

The provided code snippets demonstrate how WebForms Core can interact with various storage mechanisms available in web browsers (such as cookies, IndexedDB, local storage, session storage) to measure their size. This interaction happens through a JavaScript module that runs in the browser and communicates back to the server-side form object.

Here's a breakdown of each part:

1. Creating Sample Data

The form object is used to create sample data for different types of storage mechanisms:

  • Cookie: Adds a cookie with a specific key-value pair.
  • IndexedDB: Creates test data in IndexedDB using the CreateFormatStorage method.
  • Local Storage: Stores values in Local Storage using AddCacheValue.
  • Session Storage: Stores values in Session Storage using AddSaveValue.

2. Loading the JavaScript Module

The module is loaded into WebForms Core by specifying its location and exposing a specific method (sz_GetStorageSize) that will be used to interact with browser storage mechanisms.

csharp
1form.LoadModule("/script/module/storage_size.js", ["sz_GetStorageSize"]);

3. Calling the Module Method

The server-side code calls the module's JavaScript method using Fetch.ModuleMethod

Read the full article at DEV Community


Want to create content about this topic? Use Nemati AI tools to generate articles, social posts, and more.

Views13
On this page
Ali Nemati
Ali NematiBlogUI.author_articles
BlogUI.view_profile