c# - How to set javascript variables using MVC4 with Razor -
can format code below can set srcript variables c# code using razor?
the below not work, i've got way create easy help.
@{int proid = 123; int nonproid = 456;} <script type="text/javascript"> @{ <text> var nonid =@nonproid; var proid= @proid; window.nonid = @nonproid; window.proid=@proid; </text> } </script>
i getting design time error
you should take @ output razor page resulting. actually, need know executed server-side
, client-side
. seek this:
@{ int proid = 123; int nonproid = 456; } <script> var nonid = @nonproid; var proid = @proid; window.nonid = @nonproid; window.proid = @proid; </script>
the output should this:
depending version of visual studio using, point highlights in design-time views razor.
c# javascript asp.net-mvc razor
No comments:
Post a Comment