Created
September 5, 2013 11:33
-
-
Save IliaIdakiev/6448992 to your computer and use it in GitHub Desktop.
Razor Parse C# List To Javascript array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = JSON.parse('@Html.Raw(Json.Encode(@Model.DuplicateIds))') |
yes that works
Yes working
yes!
Thank you!!! Worked perfect
yes that works
Finally! Thanks!
I LOVE YOUUUUUUUUUUUUUUUUUU.
thanks you so much !!! it's work !!!
doesnt work
Replace Encode with Serialize and it will work.
https://stackoverflow.com/questions/50056518/ijsonhelper-does-not-contain-a-definition-for-encode
Here is an example that worked for me. I am calling a C# method from my Model that returns a list of USA locations and converting that list it to a JavaScript array.
var something = JSON.parse('@Html.Raw(Json.Serialize(Model.usaLocations()))');
this works for me. Thanks
var something = JSON.parse('@Html.Raw(Json.Serialize(Model.usaLocations()))');
Works fine, thank You!
doesn't work((
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you are lier ...........