完整文件夹的图像幻灯片放映 [英] Image slide show of full folder

查看:92
本文介绍了完整文件夹的图像幻灯片放映的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我正在使用以下编码来一张一张地滑动图像.
我要显示文件夹中所有图像的幻灯片显示.
有可能吗?
请帮帮我.


 <   div      ="  > 
<   h3  > 欢迎<  /h3  > 
<   p  >  Omaxe Ltd <  /p  > 
<   a     ="  #" 标题  打开图片"      =" 打开" <  /a  > 
<   img     ="   HRUploads/pic_omaxe.jpg"   ="  / <   img     ="   HRUploads/pic_omaxe.jpg"    class   =" 缩略图"    / >> 
<  /div  > 
<   div     ="   imageElement" <   h3  >  Omaxe Group <  /h3  > 
<   p  >  Shri Rohtas Goel ,CMD和OMAXE Group在仪式上<  /p   > 
<   a     ="  #" 标题  打开图片"      =" 打开" <  /a  > 
<   img     ="   HRUploads/97_DSC_7997.gif"   ="  / <   img     ="   HRUploads/97_DSC_7997.gif"    class   =" 缩略图"    / >> 
<  /div  > 
<   div     ="   imageElement" <   h3  > 农舍<  /h3  > 
<   p  >  APE第一批<  /p  > 
<   a     ="  #" 标题  打开图片"      =" 打开" <  /a  > 
<   img     ="   HRUploads/CMD_FARM_HOUSE_PHOTO_1.jpg"   ="  / <   img     ="   HRUploads/CMD_FARM_HOUSE_PHOTO_1.jpg"    class   =" 缩略图"    / >> 
<  /div  >  






预先感谢.

解决方案

我假设您不想复制 div 标记HTML中的每个图像,因为这会给您带来麻烦.

为了避免这种情况,您可以创建一个asp.net自定义控件来读取文件夹 div 并发出 div 标记(就像您的代码中一样).如果要存储每个文件的属性(例如用户友好名称等),则可以将其存储在XML 中,并从那里读取它.

如果您用谷歌搜索如何创建自定义控件,则有很多文章,但以下是简要的步骤.
 1 .创建类库项目使用现有的 添加项目-asp.net服务器控件.
 2 .从文件夹中读取文件(您可以将文件夹路径作为公共属性来重新使用控件).> 会为每个图像生成HTML.

要为每个图像发送HTML-共有三个选项-
 1 .您可以覆盖RenderContents方法,并且将HTML作为字符串发出.请注意,您的自定义控件派生自Web控件,因此无论您放置在哪个页面上,它都已经是页面控件的一部分.
 2 .您可以覆盖CreateChildControls  添加子控件.您可以为纯HTML 添加 asp.net图片控件文字控件.
 3 .您可以覆盖OnLoad(以防您将事件关联到图像)

最后将控件放在页面上.您可能必须先在工具箱中添加控件(使用Google进行操作,这很容易).在运行时,您会很高兴.

抱歉,我还没有准备好复制代码.我只能告诉您方向,但是您必须自己编写代码 google复制它.


尝试进行搜索会更好.

使用异步JavaScript和XML(又名Ajax)的幻灯片放映 [ http://www. codeproject.com/search.aspx?q=Slideshow+asp.net&x=12&y=8&doctypeid=1%3b2%3b3 [<div class="imageElement"> <h3>Welcome</h3> <p>Omaxe Ltd</p> <a href="#" title="open image" class="open"></a> <img src="HRUploads/pic_omaxe.jpg"class="full" /> <img src="HRUploads/pic_omaxe.jpg" class="thumbnail" /> </div> <div class="imageElement"> <h3>Omaxe Group</h3> <p>Shri Rohtas Goel, CMD, OMAXE Group at the ceremony</p> <a href="#" title="open image" class="open"></a> <img src="HRUploads/97_DSC_7997.gif"class="full" /> <img src="HRUploads/97_DSC_7997.gif" class="thumbnail" /> </div> <div class="imageElement"> <h3>Farm House</h3> <p>APE first batch</p> <a href="#" title="open image" class="open"></a> <img src="HRUploads/CMD_FARM_HOUSE_PHOTO_1.jpg"class="full" /> <img src="HRUploads/CMD_FARM_HOUSE_PHOTO_1.jpg" class="thumbnail" /> </div>






Thanks in advance.

解决方案

I am assuming you don't want to copy the div tag for each image in your HTML as it will be a maintenance headache.

To avoid it, you can create a asp.net custom control to read the folder and emit div tag (as in your code) per image. if you want to store properties for each file (like user friendly name etc) then you can store that in XML and read it from there.

There are plenty of articles if you google on how to create a custom control but here are the steps in brief.
1. Create a class library project or use existing  and add item - asp.net server control.
2. Read the files from folder (you can have folder path as a public property in order to reuse the control) and emit HTML per image.

To emit HTML per image - there are three options-
1. you can override RenderContents method and emit HTML as a string. Note your custom control derives from Web control, so its already part of page controls whichever page you put it on.
2. you cab override CreateChildControls and add child controls. you can add asp.net image control and literal control for plain HTML.
3. you can override OnLoad (in case you want to hook up events to images)

Finally place the control on your page. You might have to add your control in toolbox first (google for how to do it. its easy). Set the properties in page source or at run time and you will be good to go.

Sorry I dont have ready to copy code unfortunately. I can only tell you the direction but you will have to write the code yourself or google copy it.


It would be better if you try some search.

Slideshow using Asynchronous JavaScript and XML, a.k.a. Ajax[^]

OR

http://www.codeproject.com/search.aspx?q=Slideshow+asp.net&x=12&y=8&doctypeid=1%3b2%3b3[^]


这篇关于完整文件夹的图像幻灯片放映的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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