asp.net實現資料庫版動態網頁滑動門

來源:互聯網
上載者:User

標籤:

前端:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="滑動門.aspx.cs" Inherits="UI.滑動門" %><!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></title>  <link rel="stylesheet" href="css/style.css" /></head><body>    <form id="form1" runat="server">        <div class="solidBox">            <h3 class="solidBox_title">                <asp:ListView ID="ListTitle" runat="server">                    <ItemTemplate>                        <!--自訂模板-->                        <strong runat="server" id="Title" class="">                            <%#Eval("Title") %>                        </strong>                    </ItemTemplate>                </asp:ListView>            </h3>            <div class="solidBox_content">                <asp:ListView ID="ListContent" runat="server">                    <ItemTemplate>                        <!--自訂模板-->                        <strong runat="server" id="Content">                            <%#Eval("Content") %>                        </strong>                    </ItemTemplate>                </asp:ListView>            </div>        </div>    </form></body></html>

樣式重設:

/* * 樣式重設檔案 */body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {    margin: 0;    padding: 0;    font-weight: normal;    font-style: normal;    font-size: 12px;    font-family: inherit;}table {    border-collapse: collapse;    border-spacing: 0;}fieldset,img {    border: 0;}address,caption,cite,code,dfn,em,strong,th,var {    font-style: normal;    font-weight: normal;}ol,ul {    list-style: none;}caption,th {    text-align: left;}h1,h2,h3,h4,h5,h6 {    font-size: 100%;    font-weight: normal;}q:before,q:after {    content: ‘‘;}abbr,acronym {    border: 0;}a {    color: #333;    text-decoration: none;}a:hover {    text-decoration: underline;}/*通用父子盒子嵌套浮動問題解決,開始*/.clearfix:after {    content: ".";    display: block;    height: 0;    clear: both;    visibility: hidden;}.clearfix {    display: inline-block;}* html .clearfix {    height: 1%;}.clearfix {    display: block;}/*通用父子盒子嵌套浮動問題解決,結束*//*間隙層開始*/.space_hx {    /*橫向間隙*/        clear: both;    width: 100%;    height: 10px;    font-size: 1px;    overflow: hidden;}.space_zx {    /*縱向間隙*/        float: left;    width: 10px;    font-size: 1px;    overflow: hidden;}/*間隙層結束*/

 

樣式:

        .solidBox {            width: 330px;            height: 187px;            margin: 20px;            border-left: #CCCCCC 1px solid;            overflow: hidden;        }            /*.solidBox .solidBox_title 中間空格是父子關係,以逗號隔開是同級關係*/            .solidBox .solidBox_title {                height: 30px;                line-height: 30px;            }                .solidBox .solidBox_title div {                    float: left;                    /*變成區塊層級元素*/                    width: 109px;                    height: 30px;                    border: #CCCCCC 1px solid;                    text-align: center;                    border-left: none;                    font: 16px "微軟雅黑";                    cursor: pointer;                    /*cursor局部滑鼠的樣式*/                }                .solidBox .solidBox_title .hover {                    background: #9D9D9D;                    color: #FFF;                }            .solidBox .solidBox_content {                padding: 5px;                border: #CCCCCC 1px solid;                border-left: none;                border-top: none;                height: 157px;                width: 327px;                overflow: hidden;            }

後台:

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;namespace UI{    public partial class 滑動門 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            DBind();        }        private void DBind()        {            SqlConnection conn = new SqlConnection("Server=.;database=Test;uid=sa;pwd=x");            conn.Open();            SqlCommand cmd = new SqlCommand("select * from huadongmen",conn);            SqlDataReader reader = cmd.ExecuteReader();            List<huadongmen> list = new List<huadongmen>();            while (reader.Read())            {                huadongmen sb = new huadongmen();                sb.Title = reader[0].ToString();                sb.Content = reader[1].ToString();                list.Add(sb);            }            reader.Close();            conn.Close();            ListTitle.DataSource = list;            ListTitle.DataBind();            ListContent.DataSource = list;            ListContent.DataBind();        }    }}

附上資料庫指令碼:

create database Testgouse Testcreate table huadongmen(    title varchar(20),    content varchar(500))goinsert into huadongmen values(‘標題一‘,‘這是標題一的內容‘)insert into huadongmen values(‘標題二‘,‘這是標題二的內容‘)insert into huadongmen values(‘標題三‘,‘這是標題三的內容‘)update huadongmen set content=‘這是標題二的內容‘ where title=‘標題二‘select * from huadongmen

 

asp.net實現資料庫版動態網頁滑動門

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.