<script type="text/javascript"> $(function () { //get the Images Url $.get("/Home/GetImageList", function (data) { var imgs = []; $(data).each(function () { imgs.push(this); }); $(function () { $("#photo_container").isc({ imgArray: imgs, autoplay: true }); }); }); }); </script>
cs: Controller
public JsonResult GetImageList() { string serPath = Server.MapPath("/Content/images/pictures"); int length = serPath.Length + 1; string[] imgNameList = Directory.GetFiles(serPath); List<string> list = new List<string>(); if (imgNameList != null) { foreach (var item in imgNameList) { string img = "/Content/images/pictures/" + item.Substring(length, item.Length - length); list.Add(img); } } return this.Json(list, JsonRequestBehavior.AllowGet); }