0

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";
César
  • 9,939
  • 6
  • 53
  • 74
StR3aK
  • 9
  • 2
  • Your code does not compile: `Display` and `DisplayMode` properties should both be enumerations. Also, there is no property called `ResourceClass` on `PropertyProxyValidator`. – Randy Levy Jul 02 '10 at 18:23
  • You might take a look at this article: http://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=78. It shows how to add a `PropertyProxyValidator` to a page by using a simple extension method. – Steven Aug 17 '10 at 10:56

1 Answers1

0

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.

Community
  • 1
  • 1
Randy Levy
  • 22,566
  • 4
  • 68
  • 94
  • 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. – StR3aK Jul 03 '10 at 06:44