This is a migrated thread and some comments may be shown as answers.

Problem with CustomValidator and AllowedFileExtensions ..... not working properly.

1 Answer 108 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Snehal
Top achievements
Rank 1
Snehal asked on 23 Mar 2009, 05:50 AM

Hi,

I am checking for invalid extensions using following syntax:
 
<asp:CustomValidator runat="server" ID="CustomValidatorForRadUpload" Display="None"           ClientValidationFunction="ValidateFileExtensions">Invalid extensions.</asp:CustomValidator>

<telerik:RadUpload Width="100%" ID="radMultipleFileUpload" InitialFileInputsCount="1"
 Skin="Gray" runat="server" OnClientFileSelected="fnClicked" OnClientDeleting="fnCheckInputRowsExists"
 AllowedFileExtensions=".jpg,.jpeg,.gif,.png" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
</telerik:RadUpload>

Javascript function is as follows:
 function ValidateFileExtensions(source, arguments)
    {
      var blnIsValid;
      blnIsValid = $find("<%= radMultipleFileUpload.ClientID %>").validateExtensions();
      if (!blnIsValid)
      {
         alert("Please upload images with jpg, jpeg, gif, or png extensions.")
         return false;
      }
      return true;
    }

1)  Here after this function gets called and if user have selected invalide file extensions then.
function returns false.
But still page gets postback which i dont want to happen.

2) Also I dont want any message to be displayed on the radupload area. How can I prevent that.
Please reply.

1 Answer, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 25 Mar 2009, 12:48 PM
Hello Snehal,

There is a mistake in your validation function.  You don not need to return a value but set arguments.Value to true or false. arguments.Value is property provided by the custom validator which explicitly says if the validation is successful or not. For your convenience I have created sample project reproducing the desired scenario. You can find it as an attachment.

Greetings,
Genady Sergeev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Upload (Obsolete)
Asked by
Snehal
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or