all groups > asp.net building controls > february 2007 >
You're in the

asp.net building controls

group:

Can you set a "required attribute" on control property?


Can you set a "required attribute" on control property? Cameron Eckman
2/20/2007 10:41:08 AM
asp.net building controls: When creating a property for a server control can you set some sort of
"required attribute", so that the developer sees the browser message you see
when you leave off an attribute on a Microsoft control:

Parser Error
Description: An error occurred during the parsing of a resource required
to service this request.
Please review the following specific parse error
details and modify your source file appropriately.
Parser Error Message: The required attribute 'ContentPlaceHolderID' is
not found on 'Content' control.
Source Error:

For right now I am just throwing HttpParseException during the Init, but
that does not behave like Microsoft's controls.

Thanks.
Cameron

Re: Can you set a "required attribute" on control property? intrader
3/14/2007 2:17:03 PM
[quoted text, click to view]
It would be helpful if you include some code.

Normally, in a .net application you would provide a RequiredValidator;
something like:

<asp:RequiredValidator ID="someId" ControlToValidate="yourcontrolID"
Display="Static" InitialValue="" ErrorMessage="Please provide a value."
runat="server">

Judging by the error message you are getting indicates that you are
adding your control to a placeholder that does not exist.

AddThis Social Bookmark Button