我正在尝试以编程方式设置ImageButton的映像。我的代码如下:
String path="Images/1/";
path= path + string.Format("{0}", _ds.Tables[_bplp.SqlEntityX].DefaultView[0]["Photograph"]);
ImageButton1.ImageUrl = path;我将图片保存在我的网站文件夹图片/1,并将图像名称存储在数据库中。
当我试图在ImageButton中显示图像时,问题就在这里。
尽管经过调试,路径变量正在选择正确的图像路径。
as **"Images/1/imagename.jpg"**, but still ImageButton doesnot show image.另外,“图片”文件夹位于网站的根级。
发布于 2013-06-20 06:13:09
尝尝这个
替换这个
String path="Images/1/";使用
String path="~/Images/1/";发布于 2013-06-20 06:15:39
此外,您也可以尝试ResolveUrl();
ImageButton1.ImageUrl = ResolveUrl("~/" + path);发布于 2013-06-20 06:20:45
问题是在我的webconfig文件中,我设置了不正确的站点文件夹url,上面的代码现在运行良好。
感谢所有
https://stackoverflow.com/questions/17206433
复制相似问题