Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mvc set javascript variable from model

// Set your c# variables

@model <Your namespace>.MyModel

@{
    int myInt = MyModel.myInt;
    string myString = MyModel.myString;
}

<script>

	//In your js use the razor syntax to call your variables

    var myInt = @myInt;
    var myString = @myString;
    
    //

	var myInt = @MyModel.myInt;
    var myString = @MyModel.myString;

</script>
 
PREVIOUS NEXT
Tagged: #mvc #set #javascript #variable #model
ADD COMMENT
Topic
Name
1+6 =