Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

asp.net core 3.1 convert 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 :: display current date and time in react js 
Javascript :: how to validate age above 18 in javascript 
Javascript :: js get date from datetime 
Javascript :: convert csv to json powershell code 
Javascript :: how to add parameters to url javascript 
Javascript :: http get request js 
Javascript :: jquery datetimepicker example code 
Javascript :: set element position js 
Javascript :: how to get contrast from a color using js 
Javascript :: node-json-db example 
Javascript :: javascript stop delay 
Javascript :: js check if date is future 
Javascript :: postgresql update json field key value 
Javascript :: split a message 
Javascript :: How to fix CSS & JS not loading issue in cPanel laravel 
Javascript :: update angular to specific version 
Javascript :: hide label chratjs 
Javascript :: class with attribute selector jquery 
Javascript :: how to make slide js in owl carousel auto 
Javascript :: js array sort 
Javascript :: remove element from an array 
Javascript :: javascript infinity loop 
Javascript :: sort a dictionary by value in javascript 
Javascript :: how to change background image for a webpage 
Javascript :: js import export es5 
Javascript :: reactjs limit text display 20 200 characters 
Javascript :: click outside box jquery 
Javascript :: generate component with module angular 8 
Javascript :: Ts get first string char 
Javascript :: refresh page javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =