Search
 
SCRIPT & CODE EXAMPLE
 

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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: change ul index value with innertext 
Javascript :: 5.625/2 
Javascript :: create javascript array from datalist dynamically 
Javascript :: JsonObjectRequest 
Javascript :: youtube movie trailer angular 
Javascript :: inferred type is Array<out GroupItem 
Javascript :: how to set input of time type to current time on initialization 
Javascript :: event listener works without being clicked 
Javascript :: calculate string value in javascript 
Javascript :: mat slider in a reactve form 
Javascript :: javascript alert program 
Javascript :: p5js add canvas in middle 
Javascript :: quasar electron getPath 
Javascript :: javascript lookahead 
Javascript :: grepper add code answer 
Javascript :: gatsby creating pages from contentful 
Javascript :: message.author 
Javascript :: cargar datos de un id con inner join vue js 
Javascript :: run nodes cleos 
Javascript :: how-to-avoid-to-exceed-rate-limit-by-using-discord-js-api 
Javascript :: Noblox Shout Command 
Javascript :: chart js bars too light 
Javascript :: strpad jquery 
Javascript :: js update all links 
Javascript :: check string ifhas character in jquery 
Javascript :: modulo operator multiples, alternate values 
Javascript :: angular material nested tree 
Javascript :: jssor js slider next prev arrows position 
Javascript :: join-an-array-by-a-comma-and-a-space 
Javascript :: discord.js mention 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =