Separating JavaScript in cshtml razor views

前端 未结 6 1882
半阙折子戏
半阙折子戏 2021-01-02 17:46

I\'m new to ASP.NET/MVC3 and I\'m trying to figure out how to separate my JavaScript (which contains C#) from the rest of the HTML.

If I put them into .JS files and

6条回答
  •  没有蜡笔的小新
    2021-01-02 18:07

    As others have said writing c# to your .js file probably isnt the best idea for various reason such as caching of dynamic variables. But sometimes we all have to do things we shouldnt. And if thats the case then there is a NuGet package that allows you to write Razor syntax inside a .js file its available here http://nuget.org/packages/RazorJS

提交回复
热议问题