Documentation

From FritzAndFriends/BlazorWebFormsComponents · View interactive version

Documentation is an AI agent skill from the GitHub repository FritzAndFriends/BlazorWebFormsComponents. Provides templates, style guidelines, and a complete workflow for writing MkDocs documentation, sample pages, and navigation updates for BlazorWebFormsComponents. Covers component doc structure with Web Forms vs Blazor syntax comparisons, migration guide templates, sample page creation in AfterBlazo

How to use this skill

Skill file

Documentation Skill for BlazorWebFormsComponents

This skill provides guidance for writing documentation for the BlazorWebFormsComponents library. Use this when creating or updating component documentation, migration guides, or utility feature docs.

Documentation Philosophy

The documentation serves developers migrating ASP.NET Web Forms applications to Blazor. Every document should:

  1. Help developers understand what IS and ISN'T supported
  2. Show side-by-side Web Forms → Blazor syntax comparisons
  3. Provide practical, copy-paste-ready examples
  4. Link to original Microsoft documentation for reference

Component Documentation Template

When documenting a component, use this exact structure:

# [ComponentName]

[One paragraph describing what this component does and why it exists in this library]

Original Microsoft implementation: https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.[componentname]?view=netframework-4.8

## Features Supported in Blazor

- [List each supported feature as a bullet point]
- [Include supported events with brief description]
- [Note any Blazor-specific enhancements]

### Blazor Notes

[Any Blazor-specific implementation details or behavioral differences]

## Web Forms Features NOT Supported

- **[FeatureName]** - [Brief explanation of why not supported or what to use instead]
- **PostBackUrl** - Not supported; Blazor uses component events instead
- **ViewState serialization** - Not needed; state is preserved in component fields

## Web Forms Declarative Syntax

<asp:[ComponentName]

[All attributes from original Web Forms control]

[Alphabetically ordered]

[Include runat="server" at the end]

/>


## Blazor Syntax

<[ComponentName]

[Supported attributes only]

[Same order as Web Forms section for easy comparison]

/>


## Usage Notes

[Practical advice for migration]
[Common pitfalls to avoid]
[Performance considerations if any]

## Examples

### Basic Usage

@* Description of what this example shows *@

<[ComponentName] Property="value" OnEvent="Handler" />

@code {

void Handler()

{

// Implementation

}

}


### [Scenario Name]

@* More complex example *@


## See Also

- [Link to related component]
- [Link to migration guide if relevant]
- [Link to live sample page]

Writing Style Guidelines

Tone

Code Examples

Web Forms Syntax Blocks

Blazor Syntax Blocks

Migration Guide Template

# Migrating [Feature/Pattern]

## Overview

[What this guide covers and who it's for]

## Prerequisites

- [Required knowledge]
- [Required tools/versions]

## Step-by-Step Migration

### Step 1: [Action]

**Before (Web Forms):**

[Web Forms code]


**After (Blazor):**

[Blazor code]


[Explanation of changes]

### Step 2: [Action]

[Continue pattern...]

## Common Issues

### [Issue Name]
**Problem:** [Description]
**Solution:** [How to fix]

## Next Steps

- [What to migrate next]
- [Related guides]

Utility Feature Documentation Template

# [FeatureName]

## Background

[Why this feature existed in Web Forms]
[What problem it solved]

## Web Forms Usage

// How it was used in Web Forms


## Blazor Implementation

[How this library implements the feature]
[Key differences from Web Forms]

// How to use in Blazor


## Migration Path

[How to update existing code]
[Recommended Blazor alternatives if applicable]

## Moving On

[Recommendations for properly refactoring away from this legacy pattern]

File Naming Conventions

MkDocs Integration

After creating documentation:

  1. Add entry to mkdocs.yml in appropriate nav: section
  2. Maintain alphabetical order within categories
  3. Use descriptive nav labels matching the component name
nav:
  - Editor Controls:
    - Button: EditorControls/Button.md      # Format: "Label: path/file.md"
    - NewComponent: EditorControls/NewComponent.md

Admonition Usage

Use these sparingly for important callouts:

!!! note "Migration Tip"
    Helpful information for migration

!!! warning "Breaking Change"
    Something that differs significantly from Web Forms

!!! danger "Not Supported"
    Feature that cannot be migrated directly

!!! tip "Best Practice"
    Recommended Blazor pattern to use instead

Cross-References

Link to related documentation:

Sample Page Template (AfterBlazorServerSide Project)

When creating sample pages in samples/AfterBlazorServerSide/Components/Pages/ControlSamples/, follow this structure to help developers see both the working demo AND the code that creates it:

@page "/samples/[componentname]/[scenario]"

<PageTitle>[ComponentName] - [Scenario]</PageTitle>

<h1>[ComponentName] Sample</h1>

<p>[Brief description of what this sample demonstrates]</p>

<div class="demo-container">
    <h2>Demo</h2>

    @* The actual working component demo *@
    <Button Text="Click Me" OnClick="HandleClick" />

    @if (ClickCount > 0)
    {
        <p>Button clicked @ClickCount times</p>
    }
</div>

<div class="code-container">
    <h2>Source Code</h2>

    <pre><code class="language-razor">@@page "/samples/[componentname]/[scenario]"

&lt;h1&gt;[ComponentName] Sample&lt;/h1&gt;

&lt;Button Text="Click Me" OnClick="HandleClick" /&gt;

@@if (ClickCount &gt; 0)
{
    &lt;p&gt;Button clicked @@ClickCount times&lt;/p&gt;
}

@@code {
    private int ClickCount = 0;

    private void HandleClick()
    {
        ClickCount++;
    }
}</code></pre>
</div>

@code {
    private int ClickCount = 0;

    private void HandleClick()
    {
        ClickCount++;
    }
}

Sample Page Guidelines

  1. Two Sections Required:
  1. Code Block Formatting:
  1. Keep Demo and Code in Sync:
  1. Organization:
  1. Complex Samples:

Example: Data-Bound Component Sample

@page "/samples/gridview/basic"

<PageTitle>GridView - Basic Example</PageTitle>

<h1>GridView Sample</h1>

<p>This sample demonstrates basic GridView usage with static data.</p>

<div class="demo-container">
    <h2>Demo</h2>

    <GridView DataSource="@Products" AutoGenerateColumns="true" />
</div>

<div class="code-container">
    <h2>Source Code</h2>

    <pre><code class="language-razor">@@page "/samples/gridview/basic"

&lt;GridView DataSource="@@Products" AutoGenerateColumns="true" /&gt;

@@code {
    private List&lt;Product&gt; Products = new()
    {
        new Product { Id = 1, Name = "Product A", Price = 10.99m },
        new Product { Id = 2, Name = "Product B", Price = 20.99m }
    };

    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public decimal Price { get; set; }
    }
}</code></pre>
</div>

@code {
    private List<Product> Products = new()
    {
        new Product { Id = 1, Name = "Product A", Price = 10.99m },
        new Product { Id = 2, Name = "Product B", Price = 20.99m }
    };

    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public decimal Price { get; set; }
    }
}

Creating Sample Pages for Components

CRITICAL: Every documented component MUST have a corresponding sample page in the AfterBlazorServerSide project.

Sample Page Structure and Location

Samples are located in samples/AfterBlazorServerSide/Components/Pages/ControlSamples/[ComponentName]/

The folder structure mirrors the documentation categories:

Sample File Naming Conventions

  1. Basic Sample: Index.razor - The main/default sample for the component
  1. Additional Scenarios: [ScenarioName].razor - Named after what they demonstrate
  1. Navigation Helper: Nav.razor - Optional component listing all samples for this component

Sample Page Required Structure

Every sample page MUST include:

  1. Route: @page "/ControlSamples/[ComponentName]" or @page "/ControlSamples/[ComponentName]/[Scenario]"
  2. PageTitle: <PageTitle>[ComponentName] - [Scenario]</PageTitle>
  3. Heading: <h1>[ComponentName] Sample</h1> or <h2>[ComponentName] - [Scenario]</h2>
  4. Description: Brief explanation of what the sample demonstrates
  5. Demo Section: Working component implementation
  6. Code Display: Showing the markup and code being used (optional but recommended)

Sample Page Template

@page "/ControlSamples/[ComponentName]"
@page "/ControlSamples/[ComponentName]/[Scenario]"

<PageTitle>[ComponentName] Sample</PageTitle>

<h2>[ComponentName] - [Scenario Description]</h2>

<p>[Brief description of what this sample demonstrates]</p>

@* Optional: Navigation to other samples for this component *@
<Nav />

@* The working demo *@
<div class="demo-section">
    <[ComponentName]
        Property1="value"
        Property2="@someValue"
        OnEvent="HandleEvent" />
</div>

@* Optional but recommended: Show the results or state *@
@if (!string.IsNullOrEmpty(Message))
{
    <div class="result">@Message</div>
}

@code {
    private string Message = "";

    private void HandleEvent()
    {
        Message = "Event handled!";
    }
}

<hr />

@* Optional: Display the code being used *@
<p>Code:</p>
<code>
&lt;[ComponentName] Property1="value" OnEvent="HandleEvent" /&gt;
</code>

Creating Samples for Different Scenarios

When a component has multiple features to demonstrate, create separate sample pages:

ControlSamples/
  Button/
    Index.razor           # Basic button usage
    Style.razor           # Styling examples
    JavaScript.razor      # JavaScript integration
    Nav.razor            # Navigation between samples

Each scenario page should focus on ONE specific feature or use case.

Linking Samples in Navigation

CRITICAL: After creating sample pages, they MUST be added to the navigation tree.

Update NavMenu.razor

Location: samples/AfterBlazorServerSide/Components/Layout/NavMenu.razor

Add <TreeNode> entries under the appropriate category section:

<TreeNode Text="[Category] Components">

    @* For a component with a single sample *@
    <TreeNode Text="[ComponentName]" NavigateUrl="/ControlSamples/[ComponentName]" />

    @* For a component with multiple samples *@
    <TreeNode Text="[ComponentName]" NavigateUrl="/ControlSamples/[ComponentName]" Expanded="false">
        <TreeNode Text="Basic Usage" NavigateUrl="/ControlSamples/[ComponentName]" />
        <TreeNode Text="[Scenario 1]" NavigateUrl="/ControlSamples/[ComponentName]/[Scenario1]" />
        <TreeNode Text="[Scenario 2]" NavigateUrl="/ControlSamples/[ComponentName]/[Scenario2]" />
    </TreeNode>

</TreeNode>

Navigation Categories:

Ordering: Add new components alphabetically within their category.

Example NavMenu Updates

@* Adding a new editor control *@
<TreeNode Text="Editor Components">
    <TreeNode Text="Button" NavigateUrl="/ControlSamples/Button">
        <TreeNode Text="JavaScript Click" NavigateUrl="/ControlSamples/Button/JavaScript" />
        <TreeNode Text="Style" NavigateUrl="/ControlSamples/Button/Style" />
    </TreeNode>
    <TreeNode Text="Label" NavigateUrl="/ControlSamples/Label" />  @* New component *@
    <TreeNode Text="TextBox" NavigateUrl="/ControlSamples/TextBox" />
</TreeNode>

@* Adding a new data control with multiple samples *@
<TreeNode Text="Data Components">
    <TreeNode Text="GridView" NavigateUrl="/ControlSamples/GridView" Expanded="false">
        <TreeNode NavigateUrl="/ControlSamples/GridView" Text="Simple GridView" />
        <TreeNode NavigateUrl="/ControlSamples/GridView/AutoGeneratedColumns" Text="Autogenerated Columns" />
        <TreeNode NavigateUrl="/ControlSamples/GridView/TemplateFields" Text="Template Fields" />
    </TreeNode>
</TreeNode>

Updating the Home Page Component List

CRITICAL: After creating samples, update the component list on the home page.

Location: samples/AfterBlazorServerSide/Components/Pages/ComponentList.razor

Add links to the appropriate category column:

<div class="col-md-3">
    <h3>[Category] Controls</h3>
    <ul>
        <li><a href="/ControlSamples/ExistingComponent">ExistingComponent</a></li>
        <li><a href="/ControlSamples/NewComponent">NewComponent</a></li>  @* Add alphabetically *@
        <li><a href="/ControlSamples/OtherComponent">OtherComponent</a></li>
    </ul>
</div>

Categories:

Ordering: Add links alphabetically within each category.

Updating the Repository README

CRITICAL: After documenting a component, update the main README.md at the repository root.

Location: README.md (repository root)

For New Components

If adding a component that isn't already listed, add it to the appropriate category:

## Blazor Components for Controls

There are a significant number of controls in ASP.NET Web Forms, and we will focus on creating components in the following order:

  - Editor Controls
    - [AdRotator](docs/EditorControls/AdRotator.md)
    - [Button](docs/EditorControls/Button.md)
    - [NewComponent](docs/EditorControls/NewComponent.md)  <-- Add alphabetically with link
    - [TextBox](docs/EditorControls/TextBox.md)

For Existing Components (Adding Documentation)

If a component exists in the list without a documentation link, add the link:

Before:
    - CheckBoxList

After:
    - [CheckBoxList](docs/EditorControls/CheckBoxList.md)

README Categories

Match the category in the README to where you placed the documentation:

Ordering: Keep components alphabetically sorted within each category.

Complete Documentation Workflow

When documenting a new or existing component, follow this complete workflow:

1. Create Component Documentation

2. Add to MkDocs Navigation

3. Create Sample Page(s)

4. Update Navigation Menu

5. Update Home Page Component List

6. Update Repository README

Example: Complete Workflow for "Label" Component

# 1. Create documentation
docs/EditorControls/Label.md

# 2. Update mkdocs.yml
nav:
  - Editor Controls:
    - Label: EditorControls/Label.md

# 3. Create sample page
samples/AfterBlazorServerSide/Components/Pages/ControlSamples/Label/Index.razor

# 4. Update NavMenu.razor
<TreeNode Text="Label" NavigateUrl="/ControlSamples/Label" />

# 5. Update ComponentList.razor
<li><a href="/ControlSamples/Label">Label</a></li>

# 6. Update README.md
- [Label](docs/EditorControls/Label.md)

Quality Checklist

Before submitting documentation:

Before submitting sample pages:

Before submitting README updates:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.