mvc set javascript variable from model

Solutions on MaxInterview for mvc set javascript variable from model by the best coders in the world

showing results for - "mvc set javascript variable from model"
Lucas
22 Nov 2017
1// Set your c# variables
2
3@model <Your namespace>.MyModel
4
5@{
6    int myInt = MyModel.myInt;
7    string myString = MyModel.myString;
8}
9
10<script>
11
12	//In your js use the razor syntax to call your variables
13
14    var myInt = @myInt;
15    var myString = @myString;
16    
17    //
18
19	var myInt = @MyModel.myInt;
20    var myString = @MyModel.myString;
21
22</script>