Separating JavaScript in cshtml razor views

前端 未结 6 1876
半阙折子戏
半阙折子戏 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:03

    If anything stops working while referencing to an external js-file, perhaps you're doing something wrong. Provide us with some example code on how you reference the external file. The other way is to just place the JavaScript-code between script-tags somewhere in the file. If it is in the _Layout.cshtml, you can place it in the head-tag and in another cshtml-file, place it on top between the script-tags.

提交回复
热议问题