سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top