PropertyProxyValidator

Aug 8, 2007 at 10:21 AM
Hi all,
there is a way to use a NotNullValidator when a textbox validated from PropertyProxyValidator is empty?

Below an example:

[NotNullValidator(MessageTemplate = "Required Field")]
[StringLengthValidator(1, 200, MessageTemplate = "Length must be between {3}-{5}")]
public virtual string Description
{
get { return description; }
set { description = value; }
}

In the aspx page:
<radI:RadTextBox ID="txtDescription" runat="server" Width="200px" > </radI:RadTextBox>
<cc1:PropertyProxyValidator ID="ppvDescription" CssClass="errormessage" runat="server" PropertyName="Description" SourceTypeName="SF.Project.Lists.Entities.City" ControlToValidate="txtDescription"></cc1:PropertyProxyValidator>


If user don't type City Description I would show "Required field" and not "Length must be between 1-200".

Thanks in advance

Diego
Aug 8, 2007 at 9:30 PM
Hi Diego!

A TextBox empty have a String.Empty instead of Null value. This is why the NotNullValidator is not “validating” that.

You could use the NotNullValidator for validate a property of a entity class, for example: (see Not Null Validator topic in Enterprise Library Documentation)

[NotNullValidator]
public Company Manufacturer
{
                get
                {
                                return manufacturer;
                }
                set
                {
                                manufacturer = value;
                }
 
}


For more information about EntLib, please see this link

Hope it helps!

Sebastian Iacomuzzi
http://staff.southworks.net/blogs/siacomuzzi