I would like to force the consumer of the control to set the property to value when the control is placed on the page.
In VisualStudio, when you create an <img> without SRC or ALT attributes in a user control, it emphasizes that SRC and ALT are required attributes. I assume this is just a special tag processing by the editor, but is there a way to define similar behavior for controls?
If the control has a property defined as follows:
public object AProperty
{
get
{
if (ViewState["AProperty"] == null)
{
throw new Exception("AProperty is a required property of this control");
}
return ViewState["AProperty"];
}
set { ViewState["AProperty"] = value; }
}
Is there a way to use a custom attribute or something else that will have a flag in the designer?
source
share