Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

pass an array to javascript in asp net core list

//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 :: jquery get textarea text 
Javascript :: check if over 18 javascript 
Javascript :: focus js 
Javascript :: javascript empty cache and hard reload 
Javascript :: TypeError: getComputedStyle(...).getPropertyValue is not a function 
Javascript :: Node Sass could not find a binding for your current environment 
Javascript :: javascript un hiden element 
Javascript :: vue get props into data 
Javascript :: react native use navigation outside component 
Javascript :: selecionar valselect2 js 
Javascript :: javascript context color 
Javascript :: eslint ignore file rule 
Javascript :: scroll to div jquery 
Javascript :: simulate click jest 
Javascript :: Update nextjs to 11 
Javascript :: remove duplicates from array of objects javascript 
Javascript :: cross-origin request blocked the same origin policy disallows reading the remote resource fix in node js node js 
Javascript :: how to convert a JavaScript iterator to array 
Javascript :: get javascript min date 
Javascript :: ascending val in array using js 
Javascript :: jquery on dom change 
Javascript :: add border to view react native 
Javascript :: jqurey cdn 
Javascript :: eof while parsing 
Javascript :: js fetch send json 
Javascript :: toggle bollean value in js 
Javascript :: get the value of css properties js 
Javascript :: async storage has been extracted from react-native core 
Javascript :: useref not defined : error 
Javascript :: bootstrap modal disable close on click outside react bootstrap 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =