Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

system collections generic list 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 :: how to get current date in js 
Javascript :: validate age javascript 
Javascript :: ReferenceError: http Server is not defined 
Javascript :: get the value or text from select element using javaScript 
Javascript :: Javascript file in html angeben 
Javascript :: vuejs set 
Javascript :: how to remove menu bar in electron app without removing frame 
Javascript :: replace regex javascript 
Javascript :: find email domain javascript 
Javascript :: seleccionar value select2 js 
Javascript :: browser javascript update url without changing history 
Javascript :: google sign up react npm 
Javascript :: node js get input from console 
Javascript :: iterate over map key value javascript 
Javascript :: size of call stack js 
Javascript :: check if function is async javascript 
Javascript :: regular expression to find a string between two characters 
Javascript :: How to make "select option" select option for quantity 
Javascript :: moment date is in range 
Javascript :: ascending and descending val in array using js 
Javascript :: how to remove element from array in javascript 
Javascript :: javascript infinite loop 
Javascript :: add jquery cdn 
Javascript :: jquery event element is visible 
Javascript :: JS DOM how to add a class name to any HTML element 
Javascript :: js toggle boolean 
Javascript :: js get element type 
Javascript :: javascript split string only on first instance of specified character 
Javascript :: jquery switch class 
Javascript :: how to make required field in jquery false 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =