views:

23

answers:

1

I have added a StringLenthValidator attribute to the name field of my CSLA business object, with that I am trying to use the AJAX PropertyProxyValidator to server-validate the string inputs for that name field.

I was able to create the control at run-time and it worked fine, but it's not using the PropertyProxyValidator to report the Error Message that I specified in my Business Object attribute, instead it throws an error with the message below:

Object is not valid and can not be saved

.

Code Behind Below:

PropertyProxyValidator ppvNewName = new PropertyProxyValidator();
ppvNewName.PropertyName = "Name";
ppvNewName.ResourceClass = "MyResource";
ppvNewName.SourceTypeName = "SourceType";
ppvNewName.ControlToValidate = "txtNewName";
ppvNewName.Display = Dynamic;
ppvNewName.DisplayMode = List;
AjaxControlToolkit.WCSFExtensions.ServerSideValidationExtender ssve = new AjaxControlToolkit.WCSFExtensions.ServerSideValidationExtender();

ssve.TargetControlID = "ppvNewCategoryName";
A: 

Where do you set the id of the PropertyProxyValidator? You should set it and then call ssve.TargetControlID = ppvNewName.ID.

If you are doing this totally dynamically (besides wiring everything up properly) I think you are going to have to add your PropertyProxyValidator and ServerSideValidationExtender to your UpdatePanel.

Perhaps Adding controls dynamically to an UpdatePanel in ASP.NET AJAX can be of some help for that.

Tuzo
I set the ID and followed all your suggestion but still the same issue. It's still not using the PropertyProxyvalidator to show the error specified in my Business Object attribute, but validating the string according to the length I specified works fine.
EarlFlamiano