how to call a javascript function in foreach in mvc3 view

后端 未结 4 1037
逝去的感伤
逝去的感伤 2020-12-10 09:12

I want to call a JavaScript function in c# code in asp.net mvc3 view, but don\'t know how to do this. My code is following

Javascript Function

4条回答
  •  一个人的身影
    2020-12-10 09:37

    You can't call JS function on server side only in the views. And it wiil look like

    @foreach(var item in collection)
    {
      ...
      
      ...
    }
    

    Output html will contain several calls of this js function.

提交回复
热议问题