技术来源于同学会实践

前台设计

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="txh.aspx.cs" Inherits="txh" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>30周年同学会照片原生态无删减</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<script type="text/javascript" src="scripts/bootstrap_v30/jquery/jquery-1.8.3.min.js"></script>

<script type="text/javascript" src="scripts/layer/layer.js"></script>

<link href="sheet/StyleSheet1.css" rel="stylesheet" />

<style type="text/css">

.auto-style1 {

width: 100%;

}

</style>

</head>

<body>

<form id="form1" runat="server">

<div>

<table align="center" class="auto-style1">

<tr>

<td style="text-align: center">

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

</td>

</tr>

<tr>

<td style="text-align: center">

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="<" />

<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text=">" />

<br />

<asp:Image ID="Image1" runat="server" Height="100%" ImageAlign="Middle" Width="100%" />

</ContentTemplate>

</asp:UpdatePanel>

</td>

</tr>

<tr>

<td style="text-align: center">

<asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick" Enabled="False">

</asp:Timer>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

 

C#代码:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.IO;

using System.Collections;

using System.Data;

public partial class txh : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if(!IsPostBack)

{

string dirPath = HttpContext.Current.Server.MapPath("/imgtxh/");

if (Directory.Exists(dirPath))

{

//获得目录信息

DirectoryInfo dir = new DirectoryInfo(dirPath);

//获得目录文件列表

FileInfo[] files = dir.GetFiles("*.*");

this.Image1.ImageUrl = "~/imgtxh/" + files[0].Name;

}

}

}

protected void tpbind()

{

string dirPath = HttpContext.Current.Server.MapPath("/imgtxh/");

if (Directory.Exists(dirPath))

{

//获得目录信息

DirectoryInfo dir = new DirectoryInfo(dirPath);

//获得目录文件列表

FileInfo[] files = dir.GetFiles("*.*");

}

}

protected void Timer1_Tick(object sender, EventArgs e)

{

/*

string path = Server.MapPath("/imgtxh/");

DirectoryInfo di = new DirectoryInfo(path);

//找到该目录下的文件

//ImageUrl="~/imgtxh/1G5A7243.JPG"

FileInfo[] fis = di.GetFiles();

//ViewState["tpgs"]=fis.co

foreach (FileInfo fi in fis)

{

this.Image1.ImageUrl = "~/imgtxh/"+fi.Name;

this.Label1.Text = fi.Name;

// this.Image1.ImageUrl = path + fi.Name;

this.Timer1.Enabled = false;

break;

}

*/

}

protected void Button1_Click(object sender, EventArgs e)

{

string dirPath = HttpContext.Current.Server.MapPath("/imgtxh/");

if (Directory.Exists(dirPath))

{

//获得目录信息

DirectoryInfo dir = new DirectoryInfo(dirPath);

//获得目录文件列表

FileInfo[] files = dir.GetFiles("*.*");

int n = files.Length;//图片总数

//this.Image1.ImageUrl = "~/imgtxh/" + files[0].Name;

if(ViewState["tpsl"]!=null)

{

int wz = int.Parse(ViewState["tpsl"].ToString());//获取图片数量编号

try

{

if (wz <= 0)

{

this.Image1.ImageUrl = "~/imgtxh/" + files[0].Name;

}

else

{

ViewState["tpsl"] = wz - 1;

this.Image1.ImageUrl = "~/imgtxh/" + files[wz-1].Name;

}

}

catch

{

// this.Image1.ImageUrl

}

}

else //设置为第一章图片

{

ViewState["tpsl"] = 1;

}

}

}

protected void Button2_Click(object sender, EventArgs e)

{

string dirPath = HttpContext.Current.Server.MapPath("/imgtxh/");

if (Directory.Exists(dirPath))

{

//获得目录信息

DirectoryInfo dir = new DirectoryInfo(dirPath);

//获得目录文件列表

FileInfo[] files = dir.GetFiles("*.*");

int n = files.Length;//图片总数

//this.Image1.ImageUrl = "~/imgtxh/" + files[0].Name;

if (ViewState["tpsl"] != null)

{

int wz = int.Parse(ViewState["tpsl"].ToString());//获取图片数量编号

try

{

if (wz>=n-1)

{

this.Image1.ImageUrl = "~/imgtxh/" + files[n-1].Name;

}

else

{

ViewState["tpsl"] = wz+1;

this.Image1.ImageUrl = "~/imgtxh/" + files[wz+1].Name;

}

}

catch

{

// this.Image1.ImageUrl

}

}

else //设置为第一章图片

{

ViewState["tpsl"] = 1;

}

}

}

}

最新文章

  1. CSS 高级布局技巧
  2. 浅析:点击父控件时,子控件中的textview自动进入选中状态
  3. C#文件夹和文件操作
  4. 解决 linux [Fedora] 升级 导致VMware启动出现&quot;before you can run vmware workstation, serveral modules must be complied and loaded into the runing kernel&quot; 而无法卸载
  5. Linux目录介绍
  6. 多线程模式之MasterWorker模式
  7. 使用Jquery+EasyUI 进行框架项目开发案例解说之二---用户管理源代码分享
  8. 使用背景图修改radio、checkbox样式
  9. @EnableWebMvc,WebMvcConfigurationSupport,WebMvcConfigurer和WebMvcConfigurationAdapter区别
  10. sai u 2016
  11. php7 使用simplexml扩展处理xml
  12. 让python bottle框架支持jquery ajax的RESTful风格的PUT和DELETE等请求(新方法)
  13. shell符号解释
  14. 『TensorFlow』读书笔记_进阶卷积神经网络_分类cifar10_上
  15. HBase入门教程ppt
  16. js 判断l对象类型
  17. spring AspectJ切入点语法详解 记录以便查阅
  18. 【PHP】PHP初学者的学习线路
  19. excel 使用技巧
  20. UVA 12657 Boxes in a Line(双向链表+小技巧)

热门文章

  1. django rest framework 解析器组件 接口设计,视图组件 (2)
  2. Windows下Redis安装配置和使用注意事项
  3. CEF3相关知识汇总(不断更新)
  4. FileZilla 连接站点 编辑配置文件
  5. 解决github等外国网站突然无法链接的问题
  6. plv8 触发器使用
  7. 从三数之和看如何优化算法,递推--&gt;递推加二分查找--&gt;递推加滑尺
  8. 网络协议 13 - HTTPS 协议
  9. 这次是真的换新blog了!
  10. Softmax与Sigmoid函数的联系