技术来源于同学会实践

前台设计

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

}

}

}

}

转载于:https://www.cnblogs.com/zrprj/p/11265371.html

asp.net图片浏览器效果相关推荐

  1. 安卓学习第14课——GridView(简单图片浏览器1)

    今天学习的是GridView组件,利用的部分只是还是Adapter.imageView的知识,制作了简单图片浏览器 <LinearLayout xmlns:android="http: ...

  2. 模仿百度js浏览器控制台输出图片+文字效果

    简介 模仿百度js浏览器控制台输出图片+文字效果 演示 代码 if (window.console) {var cons = console;if (cons) {cons.log("%c\ ...

  3. php js漂浮,JavaScript_js实现图片漂浮效果的方法,本文实例讲述了js实现图片漂 - phpStudy...

    js实现图片漂浮效果的方法 本文实例讲述了js实现图片漂浮效果的方法.分享给大家供大家参考.具体分析如下: 描述:打开网页就看到不停在飘动的图片,点击连接到其他页面:起到着重强调的效果! test # ...

  4. 在Ubuntu 16.04.1 LTS上安装XnView Multi Platform图片浏览器0.83

    XnView Multi Platform是一个全平台(Windows, Linux, Mac)下的全能图片工具,类似Windows平台的美图看看,阿香婆图片浏览器等等,效果非常赞,是我在Ubuntu ...

  5. javascript图片浏览器的核心——图片预加载

    网站开发时经常需要在某个页面需要实现对大量图片的浏览,如果考虑流量的话,大可以像pconline一样每个页面只显示一张图片,让用户每看一张图片就需要 重新下载一下整个页面.不过,在web2.0时代,更 ...

  6. 7.QML Qt Quick——基于Qt Quick Controls 2实现图片浏览器

    Qt Quick Controls 2提供了一组UI控件,例如按钮,标签,复选框,滑块等(用之查之即可).用于在Qt Quick中创建用户界面.UI控件很多,这里通过一个图片浏览器的实现来逐步讲解 图 ...

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

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

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

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

  9. 【Android 应用开发】AndroidUI设计 之 图片浏览器

    图片浏览器效果图 : 源码下载地址 : -- CSDN : http://download.csdn.net/detail/han1202012/6875083 -- GitHub : https:/ ...

最新文章

  1. 成功解决源路径太长,源文件名长度大于文件系统支持的长度。请尝试将其移动到具有较短路径名称的位置,或者在执行此操作前尝试将其重命名为较短的名称
  2. swift5主线程延迟操作的几种写法
  3. 我是如何把一个15分钟的程序优化到了10秒的
  4. windows怎么将图片变为单色图片_印刷丨单色黑与四色黑
  5. 无法发送具有此谓词类型的内容正文_采用多模态细化类型进行程序合成
  6. 如何将卷积神经网络中的全连接层变成卷积层
  7. python提供了两种基本的数值类型_python数据分析(一) python当中的数据类型--数字和常用函数...
  8. 平分物品价值java_网易互联网8.8笔试_第2题平分物品_自己的题解记录
  9. 拓端tecdat|R语言风险价值:ARIMA,GARCH模型,Delta-normal法滚动估计,预测VaR(Value at Risk)和回测分析花旗公司股票时间序列数据
  10. 证明3-SAT问题是NP-complete
  11. 动画3D变形:平移、旋转、缩放
  12. ISO工具集合,好用推荐,喜欢就下载使用
  13. YC2440+wiggler小板+H-JATG+PCI转并口卡开发环境的搭建
  14. KVM 核心技术详解
  15. 2021清远市清城中学高考成绩查询,清远市清城中学中考成绩
  16. 森林图怎么分析_森林图(forest plot)怎么看|meta分析
  17. 4.7 检测脸部元素的层次结构
  18. chisel格雷码二进制转换
  19. python客户端开发自行车租赁系统_Python数据分析,自行车租赁数据分析,租赁情况怎么样?...
  20. 什么是 Object Tracking - SOT MOT

热门文章

  1. Reactjs 入门基础(一)
  2. nodejs原生模块简介
  3. jquery 获取和设置 select下拉框的值(转手册)
  4. 影著协公布的使用费收取标准
  5. oracle异地迁移,数据泵实现Oracle数据迁移到异地库
  6. 区块链技术入门,都涉及哪些编程语言?
  7. 小规模网络数据公开数据_大规模的在线公开课程曾经是100%免费的。 但是他们没有那样做。...
  8. mysql答题表设计_PHP+MYSQL问答系统中的提问和回答的表怎么设计
  9. JavaScript实时更新中国标准时间
  10. Java基础学习总结(13)——流IO