Rendering ASP.NET C# CompositeControls and web controls with a tag such as a DIV instead of a SPAN tag.

I've recently had a problem with an ASP.NET composite control where I'd added some specific styles directly to the control.

Weirdly .NET (4.6.2 in this case) would take the styles from the SPAN tag of the CompositeControl and apply them to the panels that these custom controls were in.

Very strange.

The simplest solution is to change the SPAN tag emitted by the CompositeControl to a DIV tag.


This can be done by overriding the TagKey property.


/// <summary>
/// Gets the tag key for the control.
/// </summary>
protected override HtmlTextWriterTag TagKey
{
    get { return HtmlTextWriterTag.Div; }
}

Comments

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Enable function lock for F1-F12 on HP ZBook mobile workstations