Tuesday 3 May 2016

Return Array string in ActiveX c# [Solved]

If you want to return string arry in java-script you can achieve this by using JSON serialization.
You can return a JSON string and then parse into a JavaScript object. There are a number of .NET libraries available to serialize .NET objects into JSON and vice-versa-


  • JSON.NET
  • Microsoft ASP.NET AJAX library
  • JSONSharp


Yes return as Serialize string and parse in to JavaScript is an efficient way.
Or else return as joined delimited string and split in JavaScript.


//C#
public string getArryString()
{
string[] arrstring = new string[]{"1","2","3"};
return string.Join(",", arrstring);
}
    
//Javascript
var arrstring = objActiveX.getArryString().split(',');