从数据库显示的图像背后asp.net code。通过收藏夹裹着 [英] asp.net code behind show images from DB wrapped by lightbox

查看:103
本文介绍了从数据库显示的图像背后asp.net code。通过收藏夹裹着的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中编写一个Web应用程序,
我有我的形象,我的数据库URL,我想
从我的数据库,到目前为止与收藏我的code裹显示所有图像是:

I am writing an web app in asp.net, I have in my DB URL of my images and I want to display all the images from my DB wrapped with lightbox my code so far is:

<script type="text/javascript" src="Lightbox/js/prototype.js"></script>
<script type="text/javascript" src="Lightbox/js/scriptaculous.js?load=effects,builder>        </script>
<script type="text/javascript" src="Lightbox/js/lightbox.js"></script>  

<a rel="lightbox" id="userImageLightBox" runat="server" title="profile image">
  <img id="userImage"  runat="server"  width="150"  height="146"  alt="" src=""/>
</a>

所以我的问题是:
我怎样才能使用的foreach从code的后面,当我点击插入我的所有图片
形象灯箱将激活

so my question is: how can i insert all my images using foreach from the code behind, that when i click on the image the lightbox will activate

感谢

推荐答案

使用一个ListView这将让您欣赏到的标记总量控制以及清洁HTML。使用HttpHandler的(其他Q的对等这个话题 - 做一个搜索)从数据库检索图像和服务于它。

Use a ListView which will give you total control over the markup as well as clean HTML. Use a HttpHandler (other Q's on SO on this topic - do a search) to retrieve image from DB and serve it up.

在您的ListView,使用的ItemTemplate包含标记为每个图像。图像可以通过使用以下语法对每个IMG源属性来获得。

In your ListView, use ItemTemplates to contain markup for each image. Images can be obtained by using the following syntax for each img source attribute.

src='ImageHandler.ashx?imageID=<%# Eval("ImageName")%>'

这篇关于从数据库显示的图像背后asp.net code。通过收藏夹裹着的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆