我打算做一个弹出DIV,里面只有一个图片控件,一点NOKIA N95的链接地址,会弹出N95的图片。一点N70的链接地址,会弹出N70的图片。地址是在后台读出来的,本想用JS弹出,但怎么都不对,所以又打算要写DIV,高手们,要是能把JS改对也行,我是真不知道要怎么办了。
for (int j = 0; j < 6; j++)
{
   string iURL = ds.Tables[0].Rows[jlh]["imagepath"].ToString();
   string model = ds.Tables[0].Rows[jlh]["model"].ToString();
                
   Response.Write(" <td style='width:135px;align=center'> <a href='javascript: window.open('"+iURL+"','"+model+"','menubar=1,resizable=1,width=350,height=250')>" + model+" </a> </td>");
                
   jlh++;
前台,
<asp:Image ID="Image2" runat="server" ImageAlign="Middle" ImageUrl="这里要怎么写" /><br />

解决方案 »

  1.   

    用控件绑定,不要用Response.Write
    比如用Repeater<ItemTempate>
    <a href="javascript:window.open('<%#Eval("imagepath")%>')" ><%#Eval("model")%></a>
    </ItemTemplate>
      

  2.   

    对 不要用Response.Write 输出
    用js的话 只要将图片的路径传给js函数 然后显示div 将路径赋给图片控件就可以
      

  3.   

    不能用控件,因为不可以我是在C#文件里,直接用code的出来的TABLE,6*10,每一个格里都是一个文字的超链接,所以我只能在后台的c#的基础上修改。老板的要求就是一点链接就能弹出一个窗口,里面是一图片,窗口大小要和图片符合。
      

  4.   


    function showimg(url){
        document.getElementById('img2').src=url;
    }
    <ItemTempate> 
    <a href="javascript:showimg(' <%#Eval("imagepath")%>')" > <%#Eval("model")%> </a> 
    </ItemTemplate> 
      

  5.   

    前台前台, 
    <asp:Image ID="Image2" runat="server" ImageAlign="Middle" ImageUrl="这里要怎么写" /> <br />
    什么都不用写,
    只要在后台这里
    string iURL = ds.Tables[0].Rows[jlh]["imagepath"].ToString();
       string model = ds.Tables[0].Rows[jlh]["model"].ToString();
                    
       Response.Write(" <td style='width:135px;align=center'> <a href='javascript: window.open('"+iURL+"','"+model+"','menubar=1,resizable=1,width=350,height=250')>" + model+" </a> </td>");
                    
       jlh++;改成:
    string iURL = ds.Tables[0].Rows[jlh]["imagepath"].ToString();
    Image2.ImageUrl=iURL;
       string model = ds.Tables[0].Rows[jlh]["model"].ToString();               
       Response.Write(" <td style='width:135px;align=center'> <a href='javascript: window.open('"+iURL+"','"+model+"','menubar=1,resizable=1,width=350,height=250')>" + model+" </a> </td>");
                    
       jlh++;
      

  6.   

    呵呵,我直接加上
    Image2.ImageUrl=iURL;
    报错啊,说没有这个Image2啊。我要怎么在C#文件里定义它?
    前台的的url, 
    <asp:Image ID="Image2" runat="server" ImageAlign="Middle" ImageUrl="这里要怎么写" /> 
    要改成什么样?
      

  7.   


    你改了控件<asp:Image ID="Image2" runat="server" ImageAlign="Middle" ImageUrl="" />的ID吧,怎么会没有mage2?<asp:Image ID="Image2"不是嘛!
      

  8.   

    用这种JS的方式能不能弹窗口,为什么
    Response.Write(" <td style='width:135px;align=center'> <a href='javascript: window.open('"+iURL+"','"+model+"','menubar=1,resizable=1,width=350,height=250')>" + model+" </a> </td>");