Summary
Web Forms WebControl has a TagKey property (returns HtmlTextWriterTag) and AddAttributesToRender(HtmlTextWriter) method that auto-renders the outer tag. BWFC's CustomControls.WebControl doesn't have these - custom controls must manually render their entire tag structure.
How Web Forms Does It
// Web Forms WebControl.Render() does this automatically:
public override void Render(HtmlTextWriter writer) {
AddAttributesToRender(writer); // ID, class, style, custom attrs
writer.RenderBeginTag(TagKey); // e.g., HtmlTextWriterTag.Span
RenderContents(writer); // subclass content
writer.RenderEndTag();
}
Subclasses override TagKey to change the outer element and AddAttributesToRender to add custom attributes.
Use Cases
- StarRating control renders a
<span> as outer element with CSS classes
- NotificationBell renders a
<div> with data-* attributes
- Any custom control that wraps content in a standard HTML element
Proposed Changes
Add to CustomControls.WebControl:
- Virtual
TagKey property (default: HtmlTextWriterTag.Span)
- Virtual
AddAttributesToRender(HtmlTextWriter) - auto-adds ID, CssClass, Style
- Update
Render() to auto-render outer tag
Priority
P2 - Enables cleaner custom control migration and reduces boilerplate tag management.
Summary
Web Forms
WebControlhas aTagKeyproperty (returnsHtmlTextWriterTag) andAddAttributesToRender(HtmlTextWriter)method that auto-renders the outer tag. BWFC'sCustomControls.WebControldoesn't have these - custom controls must manually render their entire tag structure.How Web Forms Does It
Subclasses override
TagKeyto change the outer element andAddAttributesToRenderto add custom attributes.Use Cases
<span>as outer element with CSS classes<div>withdata-*attributesProposed Changes
Add to
CustomControls.WebControl:TagKeyproperty (default:HtmlTextWriterTag.Span)AddAttributesToRender(HtmlTextWriter)- auto-adds ID, CssClass, StyleRender()to auto-render outer tagPriority
P2 - Enables cleaner custom control migration and reduces boilerplate tag management.