开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜