1

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.

1
  • 1
    Do you see any javascript errors? Commented Nov 14, 2012 at 21:00

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

nice!I read a lot of articles but nobody said it MUST be getters and setters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.