开发者

How to pass javascript variable to asp code with ASP.NET MVC

开发者 https://www.devze.com 2023-01-01 10:39 出处:网络
for(var i=0; i<<%=Model.Mydatalist.Count%>;i++) { //then I need to pass i to Mydatalist like Model.开发者_JAVA百科Mydatalist[i]
for(var i=0; i<<%=Model.Mydatalist.Count%>;i++)
{
//then I need to pass i to Mydatalist like Model.开发者_JAVA百科Mydatalist[i]

}

//var myJSdata="<%Model.Mydatalist["&i&"]%>"; is not working.. as system see i (i's value) as a string, and will throw exception: cannot convert string to int.


You'll need to do some kind of callback to the server for that. Once the page is loaded on the browser and the script runs it is no longer running on the server so you wont be able to access your Model.Mydatalist.

0

精彩评论

暂无评论...
验证码 换一张
取 消