In my ASP.NET Webforms project, I have created a user control that inherits from the LinkButton. This user control has a property to adjust the size by adding predefined CSS classes to the control.
Protected Overrides Sub CreateChildControls()
Dim SizeClass As String = String.Empty
If Size = SizeEnum.Large Then
SizeClass = "large"
Else
SizeClass = "small"
End If
Me.CssClass += " button " + SizeClass
Me.Controls.Add(New LiteralControl(String.Format("<span class=""l"">{0}</span><span class=""r""></span><span class=""clear""></span>", Me.Text)))
MyBase.CreateChildControls()
End Sub
It all seems pretty straightforward. However, when this control is placed within an update panel alongside other elements, the class property multiplies with each update. For example, it could result in a class property like
class=" button small button small button small button small button small"
This situation seems a bit ridiculous. Do you have any insights on why this behavior is occurring?