1

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?

4

1 回答 1

1

您如何在事件处理程序上设置组件 ID?

查看事件处理程序:

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

注意 ' 是一个 HTML 编码的字符,这可能是你的问题。试试看:

document.getElementById('Master_cphHeadContent_TimeAlert').value = GetSeconds(); return ValidateProvider(1);
于 2012-06-18T19:40:07.383 回答