我打算做一个弹出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 />
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 />
比如用Repeater<ItemTempate>
<a href="javascript:window.open('<%#Eval("imagepath")%>')" ><%#Eval("model")%></a>
</ItemTemplate>
用js的话 只要将图片的路径传给js函数 然后显示div 将路径赋给图片控件就可以
function showimg(url){
document.getElementById('img2').src=url;
}
<ItemTempate>
<a href="javascript:showimg(' <%#Eval("imagepath")%>')" > <%#Eval("model")%> </a>
</ItemTemplate>
<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++;
Image2.ImageUrl=iURL;
报错啊,说没有这个Image2啊。我要怎么在C#文件里定义它?
前台的的url,
<asp:Image ID="Image2" runat="server" ImageAlign="Middle" ImageUrl="这里要怎么写" />
要改成什么样?
你改了控件<asp:Image ID="Image2" runat="server" ImageAlign="Middle" ImageUrl="" />的ID吧,怎么会没有mage2?<asp:Image ID="Image2"不是嘛!
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>");