hi,
I keep getting an error accessing a custom object that was initialized using the pageLoad event,
While initializing the same object from xml scripting language works fine.
What am I doing worng?
---------------------------------------------------------------------------------------------------------------------------------------------
Type.registerNamespace('test');
test.TestObject = function(associatedElement) {
test.TestObject.initializeBase(this, [associatedElement]);
var _testProperty; this.initialize = function() {
test.TestObject.callBaseMethod(this, 'initialize');
} this.dispose = function() {
test.TestObject.callBaseMethod(this, 'dispose');
} this.getDescriptor = function() {
var td = test.TestObject.callBaseMethod(this, 'getDescriptor');
td.addProperty('testProperty', Number);
return td;
} this.get_testProperty = function() {
return _testProperty;
}
this.set_testProperty = function(value) {
_testProperty = value;
}}
test.TestObject.registerSealedClass('test.TestObject', Sys.UI.Control);
Sys.TypeDescriptor.addType('script', 'testObject', test.TestObject); -------------------- this is working fine ----------------------------------
<html>
....
<div id="myDiv">123</div>
<input id="Button1" onclick="javascript:showValue();" type="button" value="button" /><script type="text/javascript">
function showValue() {
var obj = $object('myDiv');
alert(obj.get_testProperty());
}
</script>
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<testObject id="myDiv" testProperty="10" />
</components>
</page>
</script>
</html>
-------------------- this code return Error ----------------------------------
<html>
......
<div id="myDiv">123</div>
<input id="Button1" onclick="javascript:showValue();" type="button" value="button" />
<script type="text/javascript">
function pageLoad() {
var obj = new test.TestObject($('myDiv'));
obj.set_testProperty(10);
}
function showValue() {
var obj = $object('myDiv');
alert(obj.get_testProperty());
}
</script>
</html>
Thanks