开发者

How to use PropertyProxyValidator with ServerSideValidationExtender at runtime

开发者 https://www.devze.com 2023-01-05 17:56 出处:网络
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 n

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.ServerSideValidationExt开发者_如何学编程ender();

ssve.TargetControlID = "ppvNewCategoryName";


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消