Question

I have getting a javascript error when attempting to reference an object in a ContentPlaceHolder that is outside the current ContentPlaceHolder (they are both on the same child page).

The error is: Microsoft JScript runtime error: Unable to set value of the property 'value': object is null or undefined

The script line where the error occurs is:

    <input type="submit" name="Master$cphMainContent$btnUnregister" value="Proceed" onclick="document.getElementById('Master_cphHeadContent_TimeAlert').value = GetSeconds(); return ValidateProvider(1);" id="cphMainContent_btnUnregister" class="netButton" />

The TimeAlert is a hidden object in the cphHeadContent ContentPlaceHodler.

Usually, I would know that the object (TimeAlert) is not visible when it is being called. However, this time it's the same page, so I can't figure out why the object is null or undefined.

Any suggestions how to resolve this error?

Was it helpful?

Solution

How are you setting the component ID on eventhandler?

Look at eventhandler:

document.getElementById(&#39;Master_cphHeadContent_TimeAlert&#39;).value = GetSeconds(); return ValidateProvider(1);

Note &#39 is a HTML encoded char, here is proprably your problem. Try it:

document.getElementById('Master_cphHeadContent_TimeAlert').value = GetSeconds(); return ValidateProvider(1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top