Requiring a file be uploaded - set focus

2 posts, 0 answers
  1. Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 04 May 2011 Link to this post

    Version: 2010.2.929.40
    VS 2010, C# 4.0

    I'm adding a CustomValidator to a RadAsyncUpload control.  I found the post that states that the ControlToValidate must NOT be set to validate this type of control, so I am not setting it.

    The validation works, and the error shows up, but Microsoft's built-in function ValidatorSetFocus(val, event) { is being overridden by the method in Telerik.Web.UI.Input.TextBox.RadInputScript.js, and that method is dependent upon the ControlToValidate and is throwing a JavaScript error when trying to set the style of the rad upload control.

    This is what is being executed in lieu of Microsoft's code.  g is always null because d.controltovalidate is undefined so getting/setting causes the "there is no 'style' property in 'null'" exception.

    if(typeof(ValidatorSetFocus)=="function"){ValidatorSetFocus=function(d,a){var g;
    if(typeof(d.controlhookup)=="string"){var f;
    }var c=false;
    }if((typeof(g)!="undefined")&&(g!=null)&&(g.tagName.toLowerCase()!="table"||(typeof(a)=="undefined")||(a==null))&&((g.tagName.toLowerCase()!="input")||(g.type.toLowerCase()!="hidden"))&&(typeof(g.disabled)=="undefined"||g.disabled==null||g.disabled==false)&&(typeof(g.visible)=="undefined"||g.visible==null||g.visible!=false)&&(IsInVisibleContainer(g)||c)){if(g.tagName.toLowerCase()=="table"&&(typeof(__nonMSDOMBrowser)=="undefined"||__nonMSDOMBrowser)){var e=g.getElementsByTagName("input");
    var b=e[e.length-1];

    Here is my client side validator for the RadAsyncUpload control.  Nothing different than what is in the forum posts except for that in my case rau does not have a GetUploadedFiles() method so I go directly to the internal property _uploadedFiles.  Not sure why that is the case.
    function radAsyncUpload_OnClientValidate(source, arguments) {
        var rau = $find("<%= rauUpload.ClientID %>");
        arguments.IsValid = rau._uploadedFiles.length > 0;

    Anyone have any thoughts??  I can't see why the RadInputControl.ValidatorSetFocus would be overriding the validation on an upload control...

  2. Genady Sergeev
    Genady Sergeev avatar
    1600 posts

    Posted 11 May 2011 Link to this post

    Hello Thad,

    Indeed, RadInput seems to override ValidatorSetFocus, I am not sure of the exact reason because according to the product backlog it was a bug fix four years ago. Anyway, can you please paste you code  (including where you set style) so that we can reproduce the issue on our side and research it. And perhaps you can try setting ID to the ControlToValidate property and check how it is going on. As a workaround it is possible to save the default ValidatorSetFocus func and once RadInput override it, to override it once again. It is a bit of a hack, but I guess it will work.

    Genady Sergeev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top