I have a string List on server that Im sending to a partial view.
List<string> list = new List<string>(); list.Add("1"); list.Add("2");
On Client Side I'm converting the list to json like this:
var stringList = @(Html.Raw(Json.Encode(this.Model.StringList))); alert(stringList );
The alert reply is: 1,2
and I should get ["1","2"]
.
Any clue on how to deal with this?
Thanks a lot.
alert(["1", "2"])
. Hit Enter. It will alert1,2
because["1", "2"].toString() === "1,2"
. You should try toconsole.log(stringList)
and see what it really is -- perhaps you already have what you seek.