Hi everyone, I need someone to explain me how to pass the strings of an array, obtained in server-side c #, in a javascript array of strings inside a razor file. I am developing in ASP.NET core MVC. I'm crazy, it looks like a simple thing, following what I've tried to do:
@{ string[] fieldsList = ViewData["FieldsList"] as string[]; @} <script> var fields_list = []; fields_list = new Array(); function fields_List() { @for (int fld = 0; fld < fieldsList.Length; fld++) { @:var field_tmp = @fieldsList[fld]; @:fields_list.push(field_tmp); } }</script>
Paolo