I am making a custom web control for my ASP page that inherits from CompositeDataBoundControl. I have a public property in the definition of my control that is required, if the user does not provide this property in the control definition on an ASP page it will break and we will get an exception. I want the compiler to throw a warning similar to the one when a user forgets to provide the 'runat' property of a Control.
"Validation (ASP.Net): Element 'asp:Button' is missing required attribute 'runat'."
Here is basically what my code looks like:
public class MyControl : CompositeDataBoundControl, IPostBackEventHandler
{
private string _someString;
public string SomeString
{
get { return _someString; }
set { _someString = value; }
}
// Other Control Properties, Functions, Events, etc.
}
I want "SomeString" to be a required property and throw a compiler warning when I build my page.
I have tried putting a Required attribute above the property like so:
[Required]
public string SomeString
{
get { return _someString; }
set { _someString = value; }
}
but this doesnt seem to work.
How can I generate such a compiler message?