原文:https://blog.csdn.net/qq_39656138/article/details/90451289

官网:https://www.swiper.com.cn/api/index.html

备注:动态数据一定需要先加载完数据再加载控件

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

<!DOCTYPE html>

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

<head runat="server">

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

   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <title></title>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.2/css/swiper.min.css" />

    <script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.2/js/swiper.min.js"></script>

    <script src="jquery-1.8.3/jquery.min.js"></script>

    <script>

        $.ajax({

            type: "post",

            dataType: 'json',

            url: 'lunbo.aspx/getImgUrl',

            data: '',

            dataType: "json",

            contentType: "application/json",

            success: function (obj) {

                function FunData(Data) {

                    var proportion = ;

                    var num = ;

                    var arr1 = [];

                    for (var i = ; i < Data.length; i++) {

                        if (i % proportion ==  && i != ) {

                            arr1.push(Data.slice(num, i));

                            num = i;

                        }

                        if ((i + ) == Data.length) {

                            arr1.push(Data.slice(num, (i + )));

                        }

                    }

                    return arr1;

                }

                //console.log(FunData(obj.d));

                var sumarr = FunData(obj.d);

                //console.log(sumarr);

                var singlearr;

                for (i = ; i < sumarr.length; i++) {

                     singlearr = sumarr[i];

                     var k = ;

                     var v = ;

                     $.each(sumarr, function (k, v) {

                         var imgUrl = singlearr[k];

                         var linkUrl = singlearr[v];

                    })

                     var t = "<div class='swiper-slide'><a href=" + singlearr[] + " > <img src=" +

                     singlearr[] + " target='_blank'  /></a></div>";

                     $('.swiper-wrapper').append(t)

                }

                var swiper = new Swiper('.swiper-container', {

                    spaceBetween: ,

                    autoplay: {

                        delay: ,

                        disableOnInteraction: false,

                    },

                    loop: true,

                    paginationType: 'custom',

                    pagination: {

                        el: '.swiper-pagination',

                        clickable: true,

                    }

                });

                swiper.el.onmouseover = function () { //鼠标放上暂停轮播

                    swiper.autoplay.stop();

                }

                swiper.el.onmouseleave = function () {

                    swiper.autoplay.start();

                }

            },

            error: function () {

                alert("頁面信息有誤!!!");

            }

        })

    </script>

    <style>

        .swiper-container {

            width: 518px;

            height: 116px;

            margin: 60px auto;

        }

        .swiper-slide {

            width: 518px;

            height: 116px;

            text-align: center;

            font-size: 18px;

            background: #fff;

        }

            .swiper-slide img {

                display: block;

                width: %;

                max-width: %;

                height: auto;

            }

        .swiper-pagination {

            width: %;

            height: 14px;

            bottom: 20px;

            left: ;

            width: %;

        }

    </style>

</head>

<body>

    <div class="swiper-container">

        <div class="swiper-wrapper">

           <%-- <div class="swiper-slide">

                <img src="img/shouban1.jpg" />

            </div>

            <div class="swiper-slide">

                <img src="img/shhouban2.jpg" />

            </div>

            <div class="swiper-slide">

                <img src="img/shouban3.jpg" />

            </div>

            <div class="swiper-slide">

                <img src="img/shouban4.jpg" />

            </div>

            <div class="swiper-slide">

                <img src="img/renwu5.jpg" />

            </div>

            <div class="swiper-slide"><a href="#">

                <img src="" /></a></div>

--%>

        </div>

        <!-- Add Pagination -->

        <div class="swiper-pagination"></div>

    </div>

</body>

</html>
using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.Web.Services;

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

//    [WebMethod]

//    public static object getImgUrl()

//    {

//        SqlConnection conn = new SqlConnection(@"server=sh-db-16;database=Web;uid=DB04DTSLink;pwd=db04dts#1234;");

//        conn.Open();

//        SqlCommand cmd = new SqlCommand(@"SELECT TOP (5) pid, imgname, picurl, linkurl, indate, enddate, frequency 

//                FROM dbo.pic  WHERE     (enddate >= GETDATE()) AND (indate <= GETDATE()) ORDER BY indate DESC;", conn);

//        object obj = cmd.ExecuteScalar();

//        return obj;

//    }

    [WebMethod]

    public static object getImgUrl()

    {

        SqlConnection conn = new SqlConnection(@"server=sh-db-16;database=Web;uid=DB04DTSLink;pwd=db04dts#1234;");

        conn.Open();

        string sql = @"SELECT TOP (5) pid, imgname, picurl, linkurl, indate, enddate, frequency 

            FROM dbo.pic  WHERE     (enddate >= GETDATE()) AND (indate <= GETDATE()) ORDER BY indate DESC";

        try { 

             SqlDataAdapter sdr = new SqlDataAdapter(sql, conn);

             DataSet ds = new DataSet();

             sdr.Fill(ds, "ds");

             DataTable dt = ds.Tables[];

             string[,] strArr = new string[ds.Tables[].Rows.Count, ds.Tables[].Columns.Count];

             for (int i = ; i < ds.Tables[].Rows.Count; i++)

             {

                 for (int j = ; j < ds.Tables[].Columns.Count;j++ ) { 

                  strArr[i,j] = ds.Tables[].Rows[i][j].ToString();

                 }

             }

             return strArr;

        }

        catch(SqlException ex) {

            throw new Exception(ex.Message);

        }

    }

}

asp.net Swiper 轮播动画的更多相关文章

  1. 微信小程序_(组件)swiper轮播图

    微信小程序swiper轮播图组件官方文档 传送门 Learn: swiper组件 一.swiper组件 indicator-dots:是否显示面板指示点[默认值false] autoplay:是否自动 ...

  2. Swiper轮播手动后不动

    最近项目首页轮播图用了Swiper轮播,今天突然发现轮播图动画初始正常但是手动换过之后就不动了,解决方法有两种,具体根据采用的情况为准: 1.autoplayDisableOnInteraction: ...

  3. jquery-自适应全屏背景轮播动画

    实时自适应浏览器窗口大小的全屏背景轮播动画 <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...

  4. jquery-抖动图组轮播动画

    JQ匀速抖动图组轮播动画 一.HTML+CSS <!DOCTYPE html> <html lang="en" xmlns="http://www.w3 ...

  5. 视频swiper轮播

    关于本次文章的内容,实际上是咪咕阅读详情页中的一个前端需求要做的效果,不过比起原需求,此次案例已经被删减掉许多部分了.音频部分舍弃,调用客户端接口舍弃,并做一些整理.最后留下的是这个精简版的案例.方便 ...

  6. swiper轮播问题之一:轮播图内容为动态数据生成时轮播图无法自动轮播

    本人在用H5做移动端项目中使用Swiper遇到的两个问题,因此加深了对Swiper的掌握,分享出来对刚开始接触Swiper的童鞋们或多或少会有帮助.        首先,new Swiper的初始化最 ...

  7. 使用Swiper轮播插件引起的探索

    提到Swiper轮播插件,小伙伴们应该不会感到陌生.以前我主要在移动端上使用,PC端使用较少. 注:这里需要注意的是,在PC端和移动端使用Swiper是不同的 官方给的版本有三个,分别是Swiper2 ...

  8. swiper轮播在ie浏览器上遇到的显示问题探索

    前言: 最近项目有一个需求,想要下图效果,鼠标指向头像图片,图片会放大同时上面的轮播会跟着切换: 鼠标移开头像图片,图片变回原来的大小 注:下图是我根据上面需求已经实现的效果,所以截图方便说明 思考: ...

  9. swiper轮播图(逆向自动切换类似于无限循环)

    swiper插件轮播图,默认的轮播循序是会从右向左,第一张,第二张,第三张,然后肉眼可见是的从第三张从左到右倒回第一张,这样就会有些视觉体验不高, ,不过还是能够用swiper本身的特性更改成无限循环 ...

随机推荐

  1. 前端面试题常考&必考之--清除浮动的方法

    浮动 问题:子元素设置了float后,脱离父元素,导致父元素无法撑开?(也就是子元素的高度没有过渡到父元素) 例子: 检查元素的效果: (三种)常用的解决办法: 1>额外标签法,添加一个空的di ...

  2. 【bzoj2073】【[POI2004]PRZ】位运算枚举子集的特技

    (上不了p站我要死了) Description 一只队伍在爬山时碰到了雪崩,他们在逃跑时遇到了一座桥,他们要尽快的过桥. 桥已经很旧了, 所以它不能承受太重的东西. 任何时候队伍在桥上的人都不能超过一 ...

  3. 设计模式学习笔记——Visitor 访问者模式

    1.定义IVisitor接口,确定变化所涉及的方法 2.封装变化类.实现IVisitor接口 3.在实体类的变化方法中传入IVisitor接口,由接口确定使用哪一种变化来实现(封装变化) 4.在使用时 ...

  4. 利用python进行数据分析--numpy基础

    随书练习,第四章  NumPy基础:数组和矢量运算 # coding: utf-8 # In[1]: # 加注释的三个方法1.用一对"""括起来要注释的代码块. # 2. ...

  5. SQL 基本查询语句

    --使用数据库 use date go --创建表班级表 create table classInfo ( classNo ,),--主键约束使用primary key identity classN ...

  6. c# Task waitAll,WhenAll

    wait 阻塞的 when是异步的非阻塞的. Task[] tlist = new Task[] { Task.Run(() => { Thread.Sleep(3000); }), Task. ...

  7. python值的引用传递和go语言的值传递

    一:值传递 实参a 原本指向地址 1638212,代表1638212这个地址的值是3.在swap函数中,实参a将值拷贝给形参a,形参a此时也在内存中拥有地址,地址= xxxx,值为3,在所有的函数体内 ...

  8. pom.xml文件设置

    一个相对完整的maven配置文件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns= ...

  9. day15生成器send方法,递归,匿名函数,max结合匿名工作原理,常用的内置函数

    复习 ''' 1.带参装饰器 - 自定义 | wraps def wrap(info) def outer1(func): from functools import wraps @wraps(fun ...

  10. pycharm社区版安装及遇到的问题

    1. 在官网上下载pycharm社区版安装包. 2. 按照该教程进行安装: https://jingyan.baidu.com/article/f00622286e92f4fbd2f0c855.htm ...