首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

用ImageButton显示图片解决方案

2012-03-18 
用ImageButton显示图片我在程序資料夾下的Picture文件中放了a.jpg,然後在版面中建了一個DataList控件,在项

用ImageButton显示图片
我在程序資料夾下的Picture文件中放了a.jpg,然後在版面中建了一個DataList控件,在项模板下加了一个ImageButton,数据库存了图片的地址。如数据库字段PhotoUrl为~\picture\chenji2.jpg。我把ImageButton.ImageURL屬性設定為数据库中的字段
如:
<asp:ImageButton   ID= "Photoes "   Width= "130 "Height= "100 "runat= "server "             CommandName= "photo "   ImageUrl= ' <%DataBinder.Eval(Container.DataItem, "PhotoUrl ")   %> '   ImageAlign= "Bottom "   />
~/Picture/a.jpg)。無法正常顯示連結的圖片,請問我哪裡弄錯了嗎?

如果把代码设定为固定的图片是可以的
如:
<asp:ImageButton   ID= "Photoes "   Width= "130 "Height= "100 "runat= "server "             CommandName= "photo "   ImageUrl= '~/Picture/a.jpg '   ImageAlign= "Bottom "   />

可是我还是想动态的显示图片呀
请各位大哥指导
万   分感谢
在线等待



[解决办法]
应在CS代码中写
Photoes.ImageUrl =
[解决办法]
初始化了吗?你给PhotoUrl赋值了吗?
[解决办法]
樓主的問題是圖片路徑錯誤.
你把數據庫中的圖片路徑改成這樣的格式:Picture/a.jpg
去掉~
[解决办法]
<asp:ImageButton ID= "Photoes " Width= "130 "Height= "100 "runat= "server " CommandName= "photo " ImageUrl= ' <%#DataBinder.Eval(Container.DataItem, "PhotoUrl ") %> ' ImageAlign= "Bottom " />

热点排行