Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

asp.net core 3.1 convert system.string[] to javascript array

//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 :: link vs uselink in React Router 
Javascript :: date of birth validation for 18 years javascript 
Javascript :: nodejs get all folders in directory 
Javascript :: js copy text to clipboard 
Javascript :: remove first char javascript 
Javascript :: javascript is valid json string 
Javascript :: await inside map js 
Javascript :: filter duplicates from array javascript 
Javascript :: nextjs path alias 
Javascript :: node json db example 
Javascript :: How to access the request body when POSTing using Node.js and Express 
Javascript :: inarray jquery 
Javascript :: javascript split string into array by comma and space 
Javascript :: get last in array javascript 
Javascript :: Triplets summing up to a target value 
Javascript :: js object for each 
Javascript :: javascript select all elements 
Javascript :: how to get a channelid discord.js 
Javascript :: javascript maximum date 
Javascript :: jquery on load 
Javascript :: import json file python online 
Javascript :: moment add 6 months 
Javascript :: javascript template strings 
Javascript :: pipe of date angular 
Javascript :: link regex 
Javascript :: delay javascript function 
Javascript :: div click outside to hide javascript 
Javascript :: jquery disable option by value 
Javascript :: adding binary numbers in javascript 
Javascript :: python json pandas Expected object or value 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =