how to use jquery with razor syntax in asp.net mvc 5?

后端 未结 3 1059
失恋的感觉
失恋的感觉 2021-01-06 04:02

I need to use jQuery to add some elements dynamically. So I looked up in the internet and I found this. It is nice and working when there is plain html elements inside singl

3条回答
  •  佛祖请我去吃肉
    2021-01-06 04:25

    You can create a partial page _MyPartial.cshtml in your Views Shared folder.

    Then in your view reference add the reference to your scripts section

    @section Scripts {
        @Html.Partial("~/Views/Shared/_MyPartial.cshtml",Model);
    }
    

    Partial page: _MyPartial.cshtml

    @model MyViewModel
    
    
    

提交回复
热议问题