Click here to Skip to main content
15,888,263 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi guys, i have a custom control, which is made up of the AJAX.NET calendar extendar and a textbox, and i have a custom validator on that control that validates the control using javascript and on the custom validator i am using a calloutvalidator extender:

C#
function doStartDateCheck(source, args)
    {
        var arg = document.getElementById('<%=calStart.FindControl("txtCalender").ClientID %>').value;
        if (arg == "")
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }



but as soon as it tries to validate i get this error:

MSIL
Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: id


Anything that you guys could do to help would be much appreciated thanks in advance!
Posted
Updated 22-Jun-11 22:40pm
v2
Comments
Sergey Alexandrovich Kryukov 23-Jun-11 4:39am    
You did not show "id" in your code, but you have it somewhere. Please find out (and make sure it's defined).
--SA
OriginalGriff 23-Jun-11 4:47am    
SA - I think "id" is the name of the parameter in the function definition: http://www.w3schools.com/jsref/met_doc_getelementbyid.asp

Best guess is that calStart.FindControl("txtCalender").ClientID is returning null - check the calStart.FindControl function and see what it is doing.
 
Share this answer
 
Comments
Member 7871170 23-Jun-11 4:53am    
I have checked this and it is not returning null, it is getting the value of the textbox
I doubt the above error has to do anything with the code sample you have shared.

Error is telling you that there is some variable named as "id" in your Javascript that is undefined and yet being used at runtime. Find it and resolve that. Use JavaScript debugging to track it down and see where exactly the error lies.
 
Share this answer
 
Comments
Member 7871170 23-Jun-11 5:00am    
I have done that and the error occurs here:
$get = $type.getElementById = function DomElement$getElementById(id, element) {
/// Finds an element by id.
/// <param name="id" type="String">The id of the element to find.</param>
/// <param name="element" domElement="true" optional="true" mayBeNull="true"></param>
/// <returns domelement="true" maybenull="true">The element, or null if it was not found.
var e = Function._validateParams(arguments, [
{name: "id", type: String},
{name: "element", mayBeNull: true, domElement: true, optional: true}
]);
if (e) throw e;
return Sys.get("#" + id, element || null);
Sandeep Mewara 23-Jun-11 5:10am    
Based on this, it looks like the 'id' passed to this method was not defined. So, it looks like 'calStart.FindControl("txtCalender").ClientID' is not returning the needed data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900