[英]How to pass the value of a list or an array from code behind to jquery?
假設我要掃描本地驅動器或特定本地文件夾中的所有圖像。 我想做的是獲取所有圖像的所有位置,並將其存儲在列表/數組中,然后,JQuery將引用幻燈片的列表/數組。
請幫我解決一下這個。
將其放在您的.aspx中應該可以解決問題。 然后,您可以從隨附的Javascript中引用imageList。 您需要包括對JavaScriptSerializer的 System.Web.Extensions.dll的引用
.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.