技术来源于同学会实践

前台设计

<%@ 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;

}

}

}

}

asp.net图片浏览器效果的更多相关文章

  1. CSS 实现图片灰度效果 兼容各种浏览器

    CSS 实现图片灰度效果 兼容各种浏览器如360浏览器 CSS实现图片灰度效果就是通过CSS样式让彩色图片呈现为灰色,相当于把一张图像的颜色模式调整为灰度,CSS可以通过以下几种方法来实现灰度效果. ...

  2. ASP.NET中使用jQuery插件实现图片幻灯效果

    参照网上的资料及提供的jQuery插件实现图片幻灯效果. 1.页面前台代码: //头部引用 <head runat="server"><title>< ...

  3. iOS开发系列--无限循环的图片浏览器

    --UIKit之UIScrollView 概述 UIKit框架中有大量的控件供开发者使用,在iOS开发中不仅可以直接使用这些控件还可以在这些控件的基础上进行扩展打造自己的控件.在这个系列中如果每个控件 ...

  4. js鼠标滚轮滚动图片切换效果

    效果体验网址:http://keleyi.com/keleyi/phtml/image/12.htm HTML文件代码: <!DOCTYPE html PUBLIC "-//W3C// ...

  5. jQuery实现鼠标经过图片变亮效果

    在线体验效果:http://hovertree.com/texiao/jquery/1.htm 以下是完整源代码: <!DOCTYPE html PUBLIC "-//W3C//DTD ...

  6. [读码][js,css3]能感知鼠标方向的图片遮罩效果

    效果图: 无意间看到过去流行的一个效果:[能感知鼠标方向的图片遮罩效果]近来不忙,就仔细的看了一看看到后来发现,网上有好多版本,谁是原著者似乎已经无法考证.读码就要读比较全面的,读像是原著的代码.代码 ...

  7. 精致3D图片切换效果,最适合企业产品展示

    这是一个精致的立体图片切换效果,特别适合企业产品展示,可立即用于实际项目中.支持导航和自动播放功能, 基于 CSS3 实现,推荐使用最新的 Chrome,Firefox 和 Safari 浏览器浏览效 ...

  8. 浅谈图片蒙版效果-webkit-mask

    会用PS的童鞋一定知道“蒙版”的概念,它可以在图片上实现一定的遮罩效果,当然这里我们不介绍ps里的蒙版,而是介绍利用CSS3的新属性-webkit-mask来实现网页中的图片遮罩效果. 大家对-web ...

  9. Magnifier.js - 支持鼠标滚轮缩放的图片放大镜效果

    Magnifier.js 是一个 JavaScript 库,能够帮助你在图像上实现放大镜效果,支持使用鼠标滚轮放大/缩小功能.放大的图像可以显示在镜头本身或它的外部容器中.Magnifier.js 使 ...

随机推荐

  1. Nginx 核心配置-长连接配置

    Nginx 核心配置-长连接配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.长连接配置参数说明 keepalive_timeout number; 设定保持连接超时时长,0 ...

  2. asp.net core mvc基于Redis实现分布式锁,C# WebApi接口防止高并发重复请求,分布式锁的接口幂等性实现

    使用背景:在使用app或者pc网页时,可能由于网络原因,api接口可能被前端调用一个接口重复2次的情况,但是请求内容是一样的.这样在同一个短暂的时间内,就会有两个相同请求,而程序只希望处理第一个请求, ...

  3. 转:宏定义的极致发挥---让你的普通C++类轻松支持IDispatch自动化接口(二)

    Posted on 2011-01-13 20:44 一桶浆糊 这是上一篇博客<宏定义的极致发挥---让你的普通C++类轻松支持IDispatch自动化接口>所展示的示例代码的改进版,改进 ...

  4. nginx 搭建上传服务器

    nginx webdav 服务器搭建 该模块可以为Http webDAV 增加PUT,DELETE,MKCOL,COPY和MOVE等方法.模块在默认编译的情况下是不被包含的,需要指定编译 ./conf ...

  5. 前端 / JavaScript 导出PDF的实践

    1.库:jspdf,自己定义一个高宽,如A4的210mm×297mm 2.让设计给背景图(包括:页眉页脚),水印图(背景透明,高宽和你的PDF单页一致)以及很多,能设计给的设计要给,因为在pdf上,排 ...

  6. 异常EXCEPTION_HIJACK(0xe0434f4e)

    简介 EXCEPTION_HIJACK,值为0xe0434f4e.意思是CLR线程劫持异常.异常劫持是CLR在挂起线程进行垃圾收集的过程中抛出的.它的抛出是为了帮助停止后恢复执行.它定义在..\clr ...

  7. php+ajax无刷新分页原生ajax实现分页最简单完整实例-完整代码,

    展示页面:index.html <html><script> function ajax_show() { // 获取当前页 var page =1; var xhr = ne ...

  8. python paramiko与linux的连接

    两种使用paramiko连接到linux服务器的代码 方式一: 1 ssh = paramiko.SSHClient() 2 ssh.set_missing_host_key_policy(param ...

  9. Spring Boot 知识笔记(热部署)

    热部署原理: 使用了两个ClassLoader,一个Classloader加载那些不会改变的类(第三方Jar包),另一个ClassLoader加载会更改的类,称为restart ClassLoader ...

  10. 数据结构与算法系列——排序(4)_Shell希尔排序

    1. 工作原理(定义) 希尔排序,也称递减增量排序算法,是插入排序的一种更高效的改进版本.但希尔排序是非稳定排序算法. 希尔排序的基本思想是:先将整个待排序的记录序列分割成为若干子序列分别进行直接插入 ...