If you set a CustomValdiator on a Rad control (any one), but do NOT set a ControlToValidate property (this is perfectly legal per MS: http://msdn.microsoft.com/en-us/library/9eee01cx(VS.80).aspx) but you DO set SetFocus = "true," it will throw a Javascript error when executed because it is trying to resolve a reference to the ControlToValidate without first checking if the property was set.
Here's a snippet of the file. The error occurs on the last line where it attempts to get the style of object "g."
It should check if g == null before doing this.
Steps to reproduce:
Sample Server side validation function:
Here's a snippet of the file. The error occurs on the last line where it attempts to get the style of object "g."
Telerik.Web.UI.RadInputControl.registerClass("Telerik.Web.UI.RadInputControl",Telerik.Web.UI.RadWebControl); if(typeof(ValidatorSetFocus)=="function"){ValidatorSetFocus=function(d,a){var g; if(typeof(d.controlhookup)=="string"){var f; if((typeof(a)!="undefined")&&(a!=null)){if((typeof(a.srcElement)!="undefined")&&(a.srcElement!=null)){f=a.srcElement; }else{f=a.target; }}if((typeof(f)!="undefined")&&(f!=null)&&(typeof(f.id)=="string")&&(f.id==d.controlhookup)){g=f; }}if((typeof(g)=="undefined")||(g==null)){g=document.getElementById(d.controltovalidate); }var c=false; if((g.style)&&(typeof(g.style.visibility)!="undefined")&&(g.style.visibility=="hidden")&&(typeof(g.style.width)!="undefined")&&(document.getElementById(g.id+"_text")||document.getElementById(g.id+"_dateInput_text"))&&(g.tagName.toLowerCase()=="input"||g.tagName.toLowerCase()=="textarea")){c=true; It should check if g == null before doing this.
Steps to reproduce:
- Drag RadInput onto form
- Drag CustomValidator onto form
- Set OnServerVadliate to a proper function and add the function to the CodeBehind file
- Set SetFocus = "true"
- Run form
- Observe "Object expected" error
Sample CustomValidator control:
<asp:CustomValidator ID="CustomValidator1" runat="server" SetFocus="true" OnServerValidate="CheckSelectedClients" CssClass="validation-error" ErrorMessage="CustomValidator1"></asp:CustomValidator>protected void CheckSelectedClients(object source, ServerValidateEventArgs args) { try { if (selSelectedClientFamily.Items.Count > 0) args.IsValid = true; else args.IsValid = false; } catch (Exception) { args.IsValid = false; } }