문제

Using the new ASP.NET MVC 3.0 Razor View Engine, is there any way to call upon it within javascript code?

In the normal view engine, you could do something like ...

<script type="text/javascript">
   $(document).ready(function() {
      function somejQueryFunction(obj) {
         <%= obj.ExecuteSomething() %>
      }
    });
</script>

But I cannot find any way to do similar with Razor.

도움이 되었습니까?

해결책

The following should work:

<script type="text/javascript">
$(document).ready(function() {
    function somejQueryFunction(obj) {
        @obj.ExecuteSomething()
    }
});
</script>

Basically any time you have <%: Expression %> or <%= Expression %> you can replace it with @Expression

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top