I noticed that on most, if not all, standard web controls in the System.Web.UI.WebControls namespace, you can add any properties you want to them without page crashes.
Take an asp: Button control for an example.
This code is absolutely correct:
<form runat="server">
<asp:Button runat="server" Text="Test button" crapAttribute="crapValue" />
</form>
Now I have a custom server control that crashes if I add arbitrary attributes to it. It accepts only attributes that have the corresponding public property.
The error I get looks something like this: "The control does not have a public property named" crapAttribute "."
I would like my user controls to be able to accept any attributes without crashing. What do I need to do for this?
I looked at the standard controls in Reflector, and they have all kinds of attributes and more, but I did not see anything that immediately caught my eye.
My user controls inherit from WebControl for what it costs.
source
share