[RESOLVED]access javascript object in rezor

<script>

var a = $(‘#name’).val();

</scrip>

@{

    int b = a      //?? can not access to a

}

Sounds interesting. But looks like, it is not possible but reverse is possible due to the sequence of execution. MVC Razor at server side (before sending to client), JS at client side.

http://stackoverflow.com/questions/11287484/using-javascript-variable-in-mvc3-razor-view-engine

Also, this makes worth to read, just to understand, why to separate js and razor code:

http://stackoverflow.com/questions/10460928/razor-if-inside-script-is-rejected-by-vs11

Leave a Reply