在html或者aspx里面有一段javascript代码。里面有如下语句
<script>
image[0]='000001.gif';
image[1]='000002.gif';
..
..
</script>
这个image[0]的值我想从数据库中取出,但是在.net的环境下,我不太会操作。如果从数据库中取出,写到这个客户端的代码里面去呢?
麻烦给我写出完整的例子

解决方案 »

  1.   

    放个隐藏控件<input type=hidden id =hidden1 runat=server /> 在后台代码(。vb)中用hidden1。value取值或赋值,js中用 document。all(‘hidden1’)。value 取值或赋值===============
    http://goody9807.611.cn
      

  2.   

    1、.net端建立一个数组,存放从数据库中取出的数据;
        假设数组名叫arySVR2、在客户端中,通过类似以下的代码把服务器端数组的内容,复制下来。
    <script>
    var image= new Array();<%
    int intCount = 0;for (intCount = 0; intCount < arySVR.Length; intCount++)
    {
    %>
        image[<%=intCount%>] = "<%=arySVR[intCount]%>";
    <%
    }
    %>
    </script>祝你成功!!!
      

  3.   

    1楼的答案什么意思?
    能够用代码分类的方法解决这个问题么?
    --------------------------
    什么叫代码分类?是不想再aspx里用<%%>么?
    其实这样用并没什么你可以在.cs中Reponse一段js脚本
    Response.Write("<script>image[0]='"+变量+"';</script>");或者你可以定义一个runat=server的hidden
    然后再服务器端赋值在客户端取值