jquery - How to use model int array variable in javascript MVC 4 -
model
public int[] mobileid{get;set;} script
var k; for(var i=0;i<3;i++) { k=@model.mobileid[i]; alert(k); } this method not working,how assign int array variable javascript var. use below method:
var k=[]; k=@html.raw(json.encode(model.mobileid));//not work
you can convert model.mobileid string separator of choice , convert javascript array:
<script> var k = "@(model.mobileid == null ? string.empty : string.join(",", model.mobileid))"; alert(k); k = k.split(","); k // k array @ point </script>
Comments
Post a Comment