国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

Simple Image Slide Show C# edition

2024-07-21 02:18:52
字體:
供稿:網(wǎng)友

最大的網(wǎng)站源碼資源下載站,

simple image slide show c# edition

by hehong yang(楊賀宏)

in scott mitchell’s article, he create a simple image slide show using asp.net with vb.net. now i rewrite it in c#. i create a sub directory photos to store the image files. and instead of using datalist control, i used dropdownlist control to list all image files. i use it in my personal web site, so you can view a live demo there( http://www17.brinkster.com/flycrane/album/default.aspx ).

soure code: default.aspx

<%@ page language="c#" %>

<%@ import namespace="system.io" %>

<script runat="server">

// insert page code here

private void page_load(object sender, system.eventargs e)

{

//get list of images

directoryinfo dirinfo= new directoryinfo( server.mappath("photos"));

fileinfo[] images= imagesfilter( dirinfo.getfiles() );

//determine the current image to show

int imageindex= 0;

if( request.querystring["n"]!=null )

imageindex= convert.toint32( request.querystring["n"] );

lbltitle.text+= path.getfilenamewithoutextension( images[imageindex].name )

+" ("+ (imageindex+1) +" of "+images.length+")";

currentimage.imageurl= "/flycrane/album/photos/"+images[imageindex].name ;

if( imageindex>0 )

lnkprev.navigateurl= "default.aspx?n=" + (imageindex - 1);

if( imageindex<images.length-1 )

lnknext.navigateurl= "default.aspx?n=" + (imageindex +1);

if(! ispostback)

{

ddlimages.datasource= images;

ddlimages.databind();

}





}

public fileinfo[] imagesfilter( fileinfo[] files )

{

arraylist newimages= new arraylist( files.length );

for( int i=0;i<files.length;i++ )

{

if( path.getextension( files[i].name.tolower() )==".jpg" ||

path.getextension( files[i].name.tolower() )==".jpeg" ||

path.getextension( files[i].name.tolower() )==".png" ||

path.getextension( files[i].name.tolower() )==".gif"

)

newimages.add(files[i]);

}

return ( fileinfo[] ) newimages.toarray( files[0].gettype() );

}

void ddlimages_selectedindexchanged(object sender, eventargs e) {

response.redirect( "default.aspx?n="+ (ddlimages.selectedindex) );

}

</script>

<html>

<head>

<title>flycrane's personal web site</title>

<link rel="stylesheet" src="/flycrane/styles/flycrane.css" />

</head>

<body>

<form runat="server">

<table cellspacing="0" cellpadding="0" width="765" align="center" border="0">

<!--dwlayouttable-->

<tbody>

<tr>

<td align="middle" width="765" bgcolor="#9999cc">

<asp:label id="lbltitle" runat="server" width="206px">you are viewing: </asp:label></td>

</tr>

<tr>

<td align="middle" width="765">

<p>

<asp:image id="currentimage" runat="server"></asp:image>

</p>

</td>

</tr>

<tr>

<td align="middle" width="765" bgcolor="#9999cc">

<asp:hyperlink id="lnkprev" runat="server">previous</asp:hyperlink>

&nbsp;<asp:hyperlink id="lnknext" runat="server">next</asp:hyperlink>

</td>

</tr>

<tr>

<td align="middle" width="765" bgcolor="#9999cc">

select one photo:

<asp:dropdownlist id="ddlimages" runat="server" onselectedindexchanged="ddlimages_selectedindexchanged" autopostback="true"></asp:dropdownlist>

</td>

</tr>

</tbody>

</table>

</form>

</body>

</html>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 泰顺县| 日喀则市| 搜索| 阿克| 惠安县| 松阳县| 西藏| 博野县| 全南县| 崇文区| 禄丰县| 剑河县| 老河口市| 平顺县| 昆明市| 保德县| 自治县| 潼关县| 霍州市| 德化县| 兴宁市| 开化县| 沂水县| 阿荣旗| 平邑县| 内乡县| 长武县| 仲巴县| 木兰县| 从化市| 皋兰县| 青神县| 英德市| 石城县| 海安县| 诸暨市| 咸宁市| 鄂托克旗| 贵定县| 乐都县| 遵义市|