I am not so good with javascript and I do hope you’re tougher than me. Here is my problem: I use MicrosoftAjax.cs framework and I use classes like this one :
MyClass =
{
teststring:null,
$constructor: function(test){
teststring = "test";
},
GetInformationFromName : function(inputname, BeginningSeparator, EndSeparator) {
alert(BeginningSeparator);
alert(EndSeparator);
},
GetId: function(inputname) {
return MyClass.GetInformationFromName(inputname,MyClass.teststring, "???");
}
}
It is a pretty straightforward function where i just want to extract information from a name given in GetId().
My problem is that In GetPerId I can see (in the debugger of visual studio) the value of MyClass.teststring. But when I debug into the call of the function and I arrive in GetInformationFromName, the value passed in parameter is null, whereas a “normal” value does not cause any trouble.
concrete example of what happens (of what i can see) :
-> GetId(“toto”)
-> MyClass.GetInformationFromName(“toto”,”&”, “???”);
-> GetInformationFromName (toto”,null, “???”)
Would you have any hint about that?
You’re not setting
teststringproperly in your constructor. Notice how, everywhere else, when calling class variables and methods you need to useMyClass.methodnameorMyClass.variablename? In your constructor, you just setteststring="test"when you should be settingMyClass.teststring="test"to override the default value ofnull.I don’t see a
GetPerIdmethod in your code snippet, so I can’t explain why VS is displaying the correct value there, but I can tell you that your constructor is setting a local variable ofteststringand you’re passing a global variable when you callGetInformationFromNameinGetID.Also, I can’t see if and when you call
$constructoranyway … so I’m not 100% sure you’re even setting the localteststringvariable.