Flag control properties as required by design

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?

+1
source share
2 answers

Microsoft.Build.Framework.Required. , , .

, , , (, , System.Web.UI.HtmlControl.Image), , litle HTML IDE.

, ,

+4

Microsoft.Build.Framework.Required, , , , .NET 4.0, :

http://forums.asp.net/t/1238319.aspx

0

All Articles