According to the docs online, the Error class has static functions
I can do the following
var err = Error.create(message, errorInfo);
without having to create a new object first. The documentation online does not explain how to create your own static functions using the MS approach.
Any ideas how I can create my own static functions?
Andre
try this:
var StaticClass =
{
//Static Variables
varInt : 0,
varString : '',
varArray : [],
StaticMethod1 : function()
{
//Accessing the Vars
StaticClass.varInt = 5;
},
StaticMethod2 : function()
{
//Calling another static method
StaticClass.StaticMethod1();
},
}
//Outside the Class:
StaticClass.StaticMethod1()
Hope this help.
When I use this approach, it seems that I can not register the class with ScriptManager anymore.
I have been digging around in MS Ajax code to see how MS creates static classes like the Error class.
Here is a snippet:
Error.__typeName = 'Error';
Error.__class = true;
Error.create = function Error$create(message, errorInfo) {
}
...
I tried to use this approach but it did not work.
Also I would be able to use a namespace instead of only a class name.
Yes you will be able to add it in ScriptManager, but won't be able to use registerClass. Unless you are not creating any component, behavior or control there is no need to use registerClass. To include namespace, add your name as you did for regular class and acess theclass with namespace.
No comments:
Post a Comment