Reputation: 137
Here is function that creates javascript objects
public IEnumerable<ScriptDescriptor>
GetScriptDescriptors()
{
ScriptControlDescriptor descriptor = new ScriptControlDescriptor("HierarchyPathControl.PathExplorer", this.ClientID);
descriptor.AddProperty("some_property", "some_value");
yield return descriptor;
}
Here is part of .js file
Type.registerNamespace("HierarchyPathControl");
HierarchyPathControl.PathExplorer = function (element) {
HierarchyPathControl.PathExplorer.initializeBase(this, [element]);
alert("invoked");
}
HierarchyPathControl.PathExplorer.prototype = {
initialize: function () {
HierarchyPathControl.PathExplorer.callBaseMethod(this, 'initialize');
alert("not invoked");
},
..............................
Why second alert invokes only if I remove this line:
descriptor.AddProperty("some_property", "some_value");
Thanks.
Upvotes: 1
Views: 109
Reputation: 6075
Check the error console if you have js error during page initialization. The problem seems to be that you didn't define some_property property in you client side class. Ensure that you have the following definition of the get/set methods inside your HierarchyPathControl.PathExplorer client side class:
get_some_property = function() {
return this._some_property;
},
set_some_property = function(value) {
if (this._some_property != value) {
this._some_property = value;
this.raisePropertyChanged('some_property');
}
}
Here basically some_property should be the name of the property you want to create.
Upvotes: 2