Answers for "mvc set javascript variable from model"

0

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>
Posted by: Guest on October-01-2020

Code answers related to "mvc set javascript variable from model"

Code answers related to "Javascript"

Browse Popular Code Answers by Language