Upgrades a Blazor component from BaseWebFormsComponent to BaseStyledComponent to gain IStyle properties like BackColor, CssClass, Font, and dimensions. Walks through base class changes, @inherits directives, style application, and duplicate property removal. Use when a component needs inline styling support, adding CSS class parameters, or migrating Web Forms style attributes to Blazor components.
95
93%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
When a component currently inherits BaseWebFormsComponent and needs IStyle properties (BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Font, ForeColor, Height, Width) on its outer rendered element.
.razor.cs// Before
public partial class MyControl : BaseWebFormsComponent
// After
public partial class MyControl : BaseStyledComponent@inherits in .razor@* Before *@
@inherits BaseWebFormsComponent
@* After *@
@inherits BaseStyledComponent<!-- Use class="@GetCssClassOrNull()" and style="...@Style" on the outermost rendered element -->
<table class="@GetCssClassOrNull()" style="border-collapse:collapse;@Style">GetCssClassOrNull() helperEither in @code {} block or in .razor.cs:
private string GetCssClassOrNull()
{
return !string.IsNullOrEmpty(CssClass) ? CssClass : null;
}Returning null when empty omits the class attribute from rendered HTML entirely.
HandleUnknownAttributes()protected override void HandleUnknownAttributes()
{
// existing sub-style attribute parsing...
this.SetFontsFromAttributes(AdditionalAttributes);
base.HandleUnknownAttributes();
}If the component previously declared its own CssClass, BackColor, etc., remove them — they now come from BaseStyledComponent.
BaseStyledComponent extends BaseWebFormsComponent — no functionality is lost.Style property on BaseStyledComponent is protected string (computed getter), not a [Parameter].[Parameter] outer styles do NOT conflict with [CascadingParameter] sub-styles.this.ToStyle() extension (from HasStyleExtensions) builds inline CSS from all IStyle properties.GetCssClassOrNull() pattern ensures clean HTML — no empty class="" attributes.Label.razor / Label.razor.cs (WI-17)Login.razor.cs, ChangePassword.razor.cs, CreateUserWizard.razor.cs (WI-52)DataList.razor.cs (WI-07 via BaseDataBoundComponent)1bd9b17
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.