Rank: Member Groups: Member
Joined: 10/4/2007 Posts: 15
|
Hi,
I am doing some evaluation of the AjaxUploader control and I noticed that you can't reference the control in the 'Control to Validate' property of the asp.net validation controls.
Is there a way to get this working or do you have a suggested workaround?
I want to make sure that a file has been uploaded before allowing form submission. Ideally postback should be prevented and a warning message displayed in the validation summary control in order to be consistent with the validation of other controls.
Thanks
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, You can use a CustomValidator to do that. Put the CustomValidator into the form and give it ClientValidationFunction. The following code demonstrates how to do it. Make sure you use build 4.0.43 to run this code:
Code: JavaScript
function check_uploader(source, arg)
{
//Here the code access an internal variable "aans".
//in build 4.0.43, this contains the list of uploaded files.
//The variable name changes from build to build, so
//this code only works on this specific build. We will
//provide a public documented function to access
//this variable in our next release
arg.IsValid = AJAXUploader1.aans.length >= 1;
}
Code: HTML/ASPX
<asp:CustomValidator ClientValidationFunction="check_uploader" .... />
Thanks
|