问一个关于前台显示图片的问题
前台index.aspx该图片的内容Html代码:
<div class= "proboxp2 ">
<img src= " <%# FrontIn.GetImg(0) %> " alt= " " width= "116 " height= "108 " class= "pro " />
<img src= " <%# FrontIn.GetImg(1) %> " alt= " " width= "116 " height= "108 " class= "pro " />
<img src= " <%# FrontIn.GetImg(2) %> " alt= " " width= "116 " height= "108 " class= "pro " />
</div>
后台app_code/FrontIn.cs文件中
//前台图片显示处理,显示具体哪个图片的URL
public static string GetImg(int pint_index)
{
string str_cmd = "select * from ProductList Order by AddDate DESC ";
string str_Return = " ";
SqlAction FillAction = new SqlAction();
DataTable dt = new DataTable();
dt = FillAction.GetTable(str_cmd );
str_Return = CutPath.GetPath (dt.Rows[pint_index][ "Picture "].ToString());
return str_Return;
}
app_code/CutPath.cs代码
public static string GetPath(string str_Path)
{
str_Path = str_Path.Replace( ".. ", " ");
str_Path = str_Path.Replace(@ "\ ",@ "/ ");
return str_Path;
}
数据库中关于该图像的存储URL为
..\ProductImage\tmp.gif
为什么我这样做,index.aspx根本就得不到图像的URL呢?各位有什么好的解决方案
教教
[解决办法]
try..
<%= FrontIn.GetImg(0) %>
[解决办法]
src= ' <%# FrontIn.GetImg(0) %> '
试下,单引号
或者你在页面中看图片的属性,它的地址是多少
[解决办法]
<%# %> 数据绑定
<%= %> 与 <% Response() %> 等价
<%$%> 没见过