Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

asp.net core 3.1 convert system.collections.generic.list`1[system.string] to javascript

//Controller content
string[] array = {"Value1", "Value2", "Value3", "Value4"};
ViewData["Array"] = array;
//OR
List<string> array = new List<string>();
array.Add("value1");
ViewData["Array"] = array.ToArray();
//View content
<script>
	$(document).ready(function () {
    	var array = @Html.Raw(Json.Serialize(ViewData["Array"]));
    	console.log("Array", erros.length);
    	$.each(array, function (key, value) {
        	console.log("Content", value);
    	});
	});
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: asp.net core 3.1 convert system.string[] to javascript array 
Javascript :: link vs NavLink in React Router 
Javascript :: remove white spaces 
Javascript :: install bun.sh 
Javascript :: How to fix stomp websocket error 
Javascript :: javascript store date in localstorage 
Javascript :: javascript get second last element in array 
Javascript :: electron Uncaught ReferenceError: require is not defined at recorder.js:1 
Javascript :: javascript log dom element 
Javascript :: asignar valselect2 js 
Javascript :: is javascript variable also an object 
Javascript :: moment add seconds 
Javascript :: number to binary javascript 
Javascript :: regex for counting characters 
Javascript :: java scipt 
Javascript :: moment js year only 
Javascript :: getkey by value js 
Javascript :: how to map through array of iterators 
Javascript :: JS get min date 
Javascript :: js encode to & 
Javascript :: last element of an array javascript 
Javascript :: get only one value from object array javascript 
Javascript :: jquery vdn 
Javascript :: react native scrollview full height 
Javascript :: react chart chart title 
Javascript :: angular window object 
Javascript :: angular cli path environment variable 
Javascript :: get all local storage 
Javascript :: xmlhttprequest response 
Javascript :: how to test usestate in jest 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =