zoukankan      html  css  js  c++  java
  • ASP.NET中使用jQuery插件实现图片幻灯效果

    参照网上的资料及提供的jQuery插件实现图片幻灯效果。

    1、页面前台代码:

    //头部引用

    <head runat="server">
    <title></title>
    <script type="text/javascript" src="scripts/jquery/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery/jquery.KinSlideshow-1.2.1.min.js"></script>
    <script type="text/javascript">
    $(function () {
    $("#focusNews").KinSlideshow();
    })
    </script>
    </head>

    <div id="focusNews" class="ifocus">
    <asp:Repeater ID="FocusList" runat="server">
    <ItemTemplate>
    <a title='<%#Eval("Title")%>' target="_blank" href='<%#Eval("Href")%>'>
    <img src='<%#Eval("Src")%>' alt='<%#Eval("Title")%>' /></a>
    </ItemTemplate>
    </asp:Repeater>
    </div>

    2、后台代码,主要是实现数据绑定:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    BindSlider();
    }
    }

    private void BindSlider()
    {
    List<MyItem> list = new List<MyItem>();
    MyItem item1 = new MyItem();
    item1.Title = "item1";
    item1.Src = "images/1.jpg";
    item1.Href = "http://www.szit.edu.cn";
    MyItem item2 = new MyItem();
    item2.Title = "item2";
    item2.Src = "images/2.jpg";
    item2.Href = "http://www.sohu.com";
    MyItem item3 = new MyItem();
    item3.Title = "item3";
    item3.Src = "images/3.jpg";
    item3.Href = "http://www.sina.com";
    list.Add(item1);
    list.Add(item2);
    list.Add(item3);
    FocusList.DataSource = list;
    FocusList.DataBind();
    }
    下载Demo

  • 相关阅读:
    树型表的设计 上海
    FTP通讯封装 上海
    线程淡写 上海
    TCP通讯故障 上海
    设计模式引导 上海
    初试Delegate 上海
    c# 扫描端口 上海
    攻读计算机研究生的看法(转载) 上海
    挖掘表字段中的汉字 上海
    新生活运动 上海
  • 原文地址:https://www.cnblogs.com/zhouhb/p/3869000.html
Copyright © 2011-2022 走看看