標籤:
前端:
<%@ 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實現資料庫版動態網頁滑動門