How to use PropertyProxyValidator with ServerSideValidationExtender at runtime

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";

Answers


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.


Need Your Help

How do you check whether a CSV file is corrupted in PHP and/or Javascript?

javascript php jquery mysql csv

I'm making an HTML5/jQuery/PHP app which involves uploading CSV files (via a drag and drop), and processing them to a MySQL database. So far, I can upload the files, and I know how to read them int...