WFC 2.0.1
dotnet add package WFC --version 2.0.1
NuGet\Install-Package WFC -Version 2.0.1
<PackageReference Include="WFC" Version="2.0.1" />
<PackageVersion Include="WFC" Version="2.0.1" />
<PackageReference Include="WFC" />
paket add WFC --version 2.0.1
#r "nuget: WFC, 2.0.1"
#:package WFC@2.0.1
#addin nuget:?package=WFC&version=2.0.1
#tool nuget:?package=WFC&version=2.0.1
WebForms Core Technology
WebForms Core is a server-side UI manipulation framework for ASP.NET Core. It enables developers to dynamically modify HTML elements such as text, styles, and states directly from the server, without relying on JavaScript frameworks.
How to work with WebForms Core in C# (Razor Pages (ASP.NET Core))
To use WebForms Core, first add WFC package from NuGet to your project. Then create a new View file similar to the one below.
Place the following view in the "Pages" directory in the project path.
View file (Index.cshtml)
@page
@model IndexModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Using WebForms Core</title>
<script type="module" src="/script/web-forms.js"></script>
</head>
<body>
<form method="post" asp-page-handler="Submit">
<label for="txt_Name">Your Name</label>
<input name="txt_Name" id="txt_Name" type="text" />
<br>
<label for="txt_FontSize">Set Font Size</label>
<input name="txt_FontSize" id="txt_FontSize" type="number" value="16" min="10" max="36" />
<br>
<label for="txt_BackgroundColor">Set Background Color</label>
<input name="txt_BackgroundColor" id="txt_BackgroundColor" type="text" />
<br>
<input name="btn_SetBodyValue" type="submit" value="Click to send data" />
</form>
@Html.Raw(ViewData["WebForms"] ?? "")
</body>
</html>
Also, create a C# class file as follows.
C# code (Index.cshtml.cs)
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using WebFormsCore;
public class IndexModel : PageModel
{
[BindProperty]
public string txt_Name { get; set; }
[BindProperty]
public int txt_FontSize { get; set; } = 16;
[BindProperty]
public string txt_BackgroundColor { get; set; }
[BindProperty]
public string btn_SetBodyValue { get; set; }
public IActionResult OnGet()
{
WebForms form = new WebForms();
form.SetTextColor("(btn_SetBodyValue)", "green");
ViewData["WebForms"] = form.ExportToHtmlComment();
return Page();
}
public IActionResult OnPostSubmit()
{
if (!string.IsNullOrEmpty(btn_SetBodyValue))
{
WebForms form = new WebForms();
form.SetFontSize("<form>", txt_FontSize);
form.SetBackgroundColor("<form>", txt_BackgroundColor);
form.SetDisabled("(btn_SetBodyValue)", true);
form.AddTag("<form>", "h3");
form.SetText("<h3>", "Welcome " + txt_Name + "!");
return Content(form.Response(), "text/html");
}
return Page();
}
}
When the form is submitted, the PageModel creates a WebForms instance,
applies UI changes using WebForms methods, and returns the generated response.
On the initial request (GET), the full view is rendered normally.
Using ViewData with WebForms Core
ViewData["WebForms"] is used when you want to render the Razor View
together with WebForms Core instructions.
In this scenario, WebForms Core generates its commands as HTML comments
(using ExportToHtmlComment()), which are embedded inside the View.
When the page is loaded, WebFormsJS detects and executes these commands
on the client side.
WebFormsJS
As you can see, the WebFormsJS script has been added in the header section of the View file above. WebFormsJS is required to process and apply server-generated UI updates on the client side.
The latest version of the WebFormsJS script is available through the link below.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.