DEV Community

Elanat Framework
Elanat Framework

Posted on

The Impact of WebFormsJS on Web Pages

What is WebFormsJS

WebFormsJS is a lightweight JavaScript library developed by Elanat that extends the capabilities of standard HTML pages by providing client-side features such as AJAX navigation, SPA behavior, automatic form submission, page state management, and communication handling, without requiring a specific server-side framework. It is also the client-side execution engine of WebForms Core (WFC), a server-driven UI manipulation technology designed to coordinate interactions between the server and the browser. WebForms Core follows a stateless architecture in which the server does not render dynamic HTML or maintain a server-side DOM tree. Instead, it generates commands that WebFormsJS interprets and executes directly against the browser's DOM. Together, these technologies provide an approach to web development in which the server orchestrates UI operations while the client handles their execution.

Note: WebFormsJS is present in the core CodeBehind framework. However, you can use it in other backend frameworks.

Get WebFormsJS

Installation via Package

JavaScript in npm (https://www.npmjs.com/package/webformsjs)

CLI

npm install webformsjs
Enter fullscreen mode Exit fullscreen mode

Download from the Elanat website

https://elanat.net/webforms-js

Github

https://github.com/webforms-core/WebFormsJS

Modern web development often requires developers to choose between traditional page navigation and JavaScript-based approaches such as AJAX and Single Page Applications (SPAs).

Traditional navigation is simple, but usually requires the server to return an entire HTML document for every request. SPA architectures provide smoother navigation but often require additional frameworks and client-side code.

WebFormsJS offers another approach.

By simply adding WebFormsJS to the head section of an HTML document, developers can change how their applications handle navigation, form submissions, browser history, page state, network communication, and user interactions.

WebFormsJS

An important distinction is that all the capabilities described in this article are available through WebFormsJS itself, without requiring the server-side WebForms Core WebForm class or its server-side architecture.

WebFormsJS can therefore be used independently as a client-side JavaScript technology.

1. Automatic AJAX Navigation and SPA Mode

One of the most important capabilities of WebFormsJS is its automatic handling of internal links.

Consider the following HTML:

<a href="/Products">Products</a>
<a href="/About">About</a>
<a href="/Contact">Contact</a>
Enter fullscreen mode Exit fullscreen mode

Normally, clicking these links causes the browser to load new documents. When WebFormsJS is included in the head section, internal links are automatically managed through XMLHttpRequest.

Developers do not need to write individual JavaScript event handlers or implement AJAX for every link.

Automatic Browser History Management

WebFormsJS goes beyond asynchronous requests by automatically managing browser navigation history.

For example, consider this navigation sequence:

  1. The user opens /Home.
  2. The user clicks the Products link. WebFormsJS loads /Products asynchronously and updates the browser URL.
  3. The user clicks the About link. The URL changes to /About, again without a full document reload.
  4. The user presses the browser's Back button. WebFormsJS handles the history navigation and restores the previous page content.
  5. The user presses Forward. The application returns to the About page.

This provides an SPA-style navigation experience while retaining traditional HTML links.

WebFormsJS can also update document titles automatically:

SetTitleBySPALink: true,
SPAGlobalTitle: "My WebSite - {{title}}",
Enter fullscreen mode Exit fullscreen mode

This allows each navigated page to have its own title while retaining a common website title.

2. Automatic Form Submission

WebFormsJS also manages HTML form submissions through XMLHttpRequest.

In traditional development, asynchronous form submission usually requires custom JavaScript to intercept the submit event, collect values, configure a request, and process the response.

WebFormsJS handles this automatically.

For example:

<form action="/Account/Login" method="post">
    <input type="text" name="Username" required>
    <input type="password" name="Password" required>
    <button type="submit">Login</button>
</form>
Enter fullscreen mode Exit fullscreen mode

When submitted, WebFormsJS sends the form data through XMLHttpRequest and includes this request header:

Post-back: true
Enter fullscreen mode Exit fullscreen mode

The server can identify the request and return only the required HTML content instead of generating the complete document.

Native HTML Form Encoding

WebFormsJS preserves standard HTML form data encoding behavior, including:

  • application/x-www-form-urlencoded
  • multipart/form-data

For example, file uploads can use an ordinary HTML form:

<form action="/Files/Upload"
      method="post"
      enctype="multipart/form-data">

    <input type="file" name="UploadedFile" required>
    <button type="submit">Upload</button>
</form>
Enter fullscreen mode Exit fullscreen mode

There is no need to manually serialize form fields or implement a separate AJAX upload mechanism.

Extended HTTP Method Support

Traditional HTML forms natively support GET and POST. WebFormsJS extends this capability by allowing additional HTTP methods through the form's method attribute.

For example:

<form action="/Products/Update" method="put">
    <input type="hidden" name="ProductId" value="125">
    <input type="text" name="ProductName" value="Product A">
    <button type="submit">Update</button>
</form>
Enter fullscreen mode Exit fullscreen mode

A DELETE request can also be submitted:

<form action="/Products/Delete" method="delete">
    <input type="hidden" name="ProductId" value="125">
    <button type="submit">Delete</button>
</form>
Enter fullscreen mode Exit fullscreen mode

This makes it possible to use HTTP methods such as GET, POST, PUT, and DELETE directly in HTML forms without implementing separate JavaScript request handlers.

3. Returning HTML Without the Layout

Another significant advantage of WebFormsJS is reducing unnecessary HTML transfers.

In traditional navigation, the server usually returns the entire document, including shared elements such as headers, navigation menus, and footers.

With WebFormsJS, requests include:

Post-back: true
Enter fullscreen mode Exit fullscreen mode

The server can recognize these requests and return only the page content without the shared layout.

For example, instead of returning an entire HTML document, the server can return:

<h1>Products</h1>
<p>Product information...</p>
Enter fullscreen mode Exit fullscreen mode

WebFormsJS inserts the returned HTML into a configurable response location. The recommended default is the main element.

<body>
    <header>
        <!-- Shared header -->
    </header>

    <nav>
        <!-- Navigation -->
    </nav>

    <main>
        <!-- Page content -->
    </main>

    <footer>
        <!-- Shared footer -->
    </footer>
</body>
Enter fullscreen mode Exit fullscreen mode

Only the content inside main is replaced. Other parts of the document remain intact.

This reduces repeated HTML generation, unnecessary network traffic, and the transmission of shared layout elements.

4. Page State Preservation

Replacing page content should not necessarily mean losing the user's current state.

WebFormsJS provides page state management capabilities that help preserve and restore relevant information during navigation and DOM updates.

This can include input values, scroll positions, and other interactive element states.

As a result, applications can provide a more consistent navigation experience without treating every content replacement as an entirely new page.

5. Request Management and Reliability

WebFormsJS provides several options for controlling request execution and handling communication problems.

For example:

IgnoreEmptyResult: false,

UseRetryRequest: false,
MaxRetryCount: 3,
RetryRequestInterval: 3000,

UseQueue: true,
QueueLockDuration: 100,

UseQueueForWebFormsValue: true,

UseDebounceDelay: true,
QueueDebounceDelay: 200,
Enter fullscreen mode Exit fullscreen mode

These settings provide capabilities such as:

  • Retry Request: Automatically retry failed requests according to configured limits and intervals.
  • Request Queue: Coordinate requests and control their execution order.
  • Queue Lock: Configure the queue locking duration.
  • Debounce: Prevent rapid repeated operations from generating unnecessary requests.
  • Empty Result Handling: Configure how empty responses are processed.

These features are particularly useful when multiple interactions occur rapidly or when requests depend on one another.

6. Loading Animations and Progress Indicators

WebFormsJS includes configurable loading animations and progress indicators.

UseProgressBar: true,
UseLoader: true,

UseLoaderForFirstPageLoad: true,
UseLoaderForCommentBack: false,
UseLoaderForFrontBack: true,
UseLoaderForWasmBack: true,

LoaderIgnoreTimeout: 100,
LoaderMinimumDuration: 500,
HideLoaderTimeout: 5000,

HideLoaderWhenUpload: true,
HideLoaderAfterUploaded: 1024 * 1024,
Enter fullscreen mode Exit fullscreen mode

Developers can control loader behavior for different request types, configure minimum display durations, manage hiding timeouts, and customize feedback during file uploads.

This provides centralized loading management without requiring separate animation implementations for individual interactions.

7. Data Transfer Optimization

WebFormsJS also provides configuration options for compression and checksum handling.

UseGzipFileSend: false,

UseGzipFileSendIgnoreList: [
    "zip", "gzip", "rar"
],

UseGzipDataSend: false,
UseGzipDataSendLargerThan: 5 * 1024,

SendChecksum: false,
ChecksumName: "checksum",
Enter fullscreen mode Exit fullscreen mode

These options allow developers to configure Gzip compression for file and data transmission, exclude already-compressed file formats, define minimum compression thresholds, and enable checksum transmission.

This provides additional control over network communication and data transfer.

8. Error Handling and Localization

WebFormsJS provides configurable messages for connection errors, execution problems, WebSocket communication, SSE connections, and other operations.

For example:

ConnectionErrorMessage: "Connection Error",
Enter fullscreen mode Exit fullscreen mode

Developers can also customize the language resources used by WebFormsJS.

For example:

ConnectionErrorLang: "Connection error",
WebSocketErrorLang: "WebSocket error",
WebSocketConnectedLang: "WebSocket connected",
SSEConnectedLang: "SSE Connected",
SSEReconnectingLang: "SSE Reconnecting",
Enter fullscreen mode Exit fullscreen mode

Form validation messages can also be translated:

ValidityValueMissing:
    "Please fill out this field",

ValidityTypeMismatch:
    "Please enter a valid value",

ValidityTooLong:
    "Maximum length is {{maxLength}} characters",

ValidityTooShort:
    "Minimum length is {{minLength}} characters",
Enter fullscreen mode Exit fullscreen mode

Developers can provide their own translations for these messages, making it possible to create multilingual applications without maintaining separate JavaScript implementations.

9. Independent Client-Side Capabilities

The features described in this article demonstrate that WebFormsJS is not exclusively a client-side execution component for WebForms Core.

Even without using the server-side WebForm class, developers can use WebFormsJS for:

  • Automatic AJAX navigation and SPA-style browser history.
  • Automatic form submission and extended HTTP methods.
  • HTML content replacement.
  • Page state preservation.
  • Request queues, retries, and debounce management.
  • Loading animations and progress indicators.
  • Data compression and checksum options.
  • Error handling and localization.
  • WebSocket and Server-Sent Events communication.

These capabilities can be integrated into existing HTML applications and used alongside different backend technologies.

Conclusion

Adding a single JavaScript file to the head section can significantly change how a traditional web application operates.

WebFormsJS provides automatic asynchronous navigation, SPA-style browser history, form submission, extended HTTP method support, page state management, request coordination, loading indicators, data transfer options, and localization.

Developers do not need to abandon traditional HTML or adopt a complete SPA framework to benefit from these capabilities.

Most importantly, everything discussed in this article is available through WebFormsJS independently, without requiring the server-side WebForms Core WebForm class.

WebFormsJS is therefore more than a tool for executing server-generated UI commands. It is also an independent client-side JavaScript technology that can improve traditional web development workflows and provide a foundation for more advanced server-orchestrated UI architectures.

Related links

CodeBehind on GitHub:
https://github.com/elanatframework/CodeBehind

CodeBehind in NuGet:
https://www.nuget.org/packages/CodeBehind/

CodeBehind page:
https://elanat.net/codebehind

Top comments (0)