Files
dotnet/Documentation/compatibility/aspnet-fix-handling-input-and-label-attributes-for-webforms-checkbox-control.md
Ron Petrusha 4835ea5b9c Miscellaneous corrections and new index (#1029)
* Corrected scope, generated new index

* Miscellaneous corrections, regenerate index

* Removed duplicate topics, regenerated index
2019-04-29 12:42:00 -07:00

1.2 KiB

ASP.NET Fix handling of InputAttributes and LabelAttributes for WebForms CheckBox control

Version Introduced

4.8

Change Description

For applications that target .NET Framework 4.7.2 and earlier versions, xref:System.Web.UI.WebControls.CheckBox.InputAttributes?displayProperty=nameWithType and xref:System.Web.UI.WebControls.CheckBox.LabelAttributes?displayProperty=nameWithType that are programmatically added to a WebForms xref:System.Web.UI.WebControls.CheckBox control are lost after postback. For applications that target .NET Framework 4.8 or later versions, they are preserved after postback.

For the correct behavior for restoring attributes on postback, set the targetFrameworkVersion to 4.8 or higher. For example:

    <configuration>
      <system.web>
        <httpRuntime targetFramework="4.8"/>
      </system.web>
    </configuration>

Setting it lower, or not at all, preserves the old incorrect behavior.

Affected APIs

  • T:System.Web.UI.WebControls.CheckBox

Category

ASP.NET