日期:2014-05-18  浏览次数:20845 次

我要把javascript数组的值改为从后台读取,怎么改写
<script type="text/javascript">  
var tv = new TransView([
  {'img':'Images/product/Middle/20081104100009.jpg', 'text':'', 'url':'javascript:var page = window.open("ImagePreview.aspx","","width=400,height=400");page.document.write("<img src=Images/product/Big/20081104100009.jpg border=0 />");page.document.write("<br/>");page.document.write("<a class=AdminPageText href=javascript:window.close()>[关闭窗口]</a>");'},
  {'img':'Images/product/Middle/20081104111440.jpg', 'text':'', 'url':'javascript:var page = window.open("ImagePreview.aspx","","width=400,height=400");page.document.write("<img src=Images/product/Big/20081104111440.jpg border=0 />");page.document.write("<br/>");page.document.write("<a class=AdminPageText href=javascript:window.close()>[关闭窗口]</a>");'}
  ], "idPicShow", "idPicList", "idPicText", { ClassOn: "on" }
);
我要将数组的图片信息改为从后台读取:
public ArrayList imageArrList =new ArrayList();



 imageArrList.Add(里面的值仿照上面的怎么改写,我写的提示未定义SYSTEM)




------解决方案--------------------
你直接在后台里写JS然后用
page.ClientScript.RegisterStartupScript(page.GetType(),"Message", 上面的脚本);
------解决方案--------------------
不是使用数组,使用字符串变量,把数组连接成你需要的json数据结构格式,然后赋值给js变量

C# code
//page是你的类吗??js没有page这种对象的,确认js没错误??
public string ArrStr="([{'img':'Images/product/Middle/20081104100009.jpg', 'text':'', 'url':'javascript:var page = window.open(\"ImagePreview.aspx\",\"\",\"width=400,height=400\");page.document.write(\" <img  src=Images/product/Big/20081104100009.jpg border=0 />\");page.document.write(\"<br/>\");page.document.write(\" <a class=AdminPageText href=javascript:window.close()>[关闭窗口] </a>\");'},"
+"{'img':'Images/product/Middle/20081104111440.jpg', 'text':'', 'url':'javascript:var page = window.open(\"ImagePreview.aspx\",\"\",\"width=400,height=400\");page.document.write(\" <img  src=Images/product/Big/20081104111440.jpg border=0 />\");page.document.write(\" <br/>\");page.document.write(\" <a class=AdminPageText href=javascript:window.close()>[关闭窗口] </a>");'}]";

------解决方案--------------------
把数组的值放到隐藏域,后台取隐藏域的值就可以了