[英]How to pass the value of a list or an array from code behind to jquery?
Let's say I want to scan my local drive or a particular local folder for all images. 假设我要扫描本地驱动器或特定本地文件夹中的所有图像。 What I want to do is get all the location of all the images and store it in a list/array then after that JQuery will going to refer to the list/array for a slideshow.
我想做的是获取所有图像的所有位置,并将其存储在列表/数组中,然后,JQuery将引用幻灯片的列表/数组。
Please help me with this. 请帮我解决一下这个。
Putting this in your .aspx should do the trick. 将其放在您的.aspx中应该可以解决问题。 You can then reference imageList from your included Javascript.
然后,您可以从随附的Javascript中引用imageList。 You need to include a reference to System.Web.Extensions.dll for JavaScriptSerializer
您需要包括对JavaScriptSerializer的 System.Web.Extensions.dll的引用
.aspx Page: .aspx页:
<html>
<head>
<script>
var imageList = <%=new JavaScriptSerializer().Serialize(System.IO.Directory.GetFiles(@"C:\MyImages\", "*.png")) %>
for(var i in imageList) {
console.log(imageList[i]);
}
</script>
...
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.