基于ASP.NET的新聞管理系統(三)代碼展示

5.1.1欄目部分

增加欄目(addLanMu.aspx):

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

<head?runat="server">

????<title></title>

????<link?rel="stylesheet"?type="text/css"?href="../css/style.css"?/>

????<style?type="text/css">

????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}

????????#submitLanMu,#backlanmu

????????{

????????????color:White;

????????????width:100px;

????????????height: 35px;

????????outline: none;

????????margin:10px?50px;

????????border: none;

????????

????????line-height: 35px;

????????border-radius: 50px;

????????position: relative;

????????border: rgba(255,255,255,0.2)?2px?solid?;

????????color: var(--color);

????????????-webkit-transition: 0.25s;

????????????transition: 0.25s;

??????????}

????????#submitLanMu:hover,#submitLanMu:focus{box-shadow: inset?0?0?0?2em?var(--hover);}

????????#submitLanMu{--color: #a972cb;--hover: #cb72aa;}

????????#backlanmu:hover,#backlanmu:focus?{box-shadow: inset?-3.5em?0?0?0?var(--hover),?inset?3.5em?0?0?0?var(--hover);}

????????#backlanmu{--color: #ff7f82; --hover: #ffdc7f;}

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

?????????<div?id="addLanMuDiv">

????????????<div?style=" text-align:center">增加欄目</div>

????????????<div?class="addUserClass">

????????????????<asp:Label?ID="Label1"?Text="欄目名:"?runat="server"?/>

????????????????<asp:TextBox?ID="addLanMuName"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>

????????????</div>

????????????<br?/>

????????????<asp:Button?Text="確定"?runat="server"?ID="submitLanMu"?

????????????????οnclick="submitUser_Click"?/>

?????????????<asp:Button?ID="backlanmu"?runat="server"?οnclick="back_Click"?Text="返回"?/>

????????</div>

????</div>

????</form>

</body>

</html>

?

編輯欄目(editLanMu.aspx):

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

<head?runat="server">

????<title></title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

?????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}

?????????#submitEditLanMu,#backtolanmu

?????????{

?????????????margin: 30px?20px;

??????????????padding: 15px?20px;

??????????????border-radius: 10px;

??????????????border: 2px?solid;

??????????????font: 16px?'Open Sans',?sans-serif;

??????????????text-transform: uppercase;

??????????????background: none;

??????????????outline: none;

??????????????cursor: pointer;

??????????????-webkit-transition: all?.5s;

??????????????transition: all?.5s;

??????????}

??????????#submitEditLanMu,#backtolanmu?{color: #CEFFF1;border-color: #CEFFF1; overflow: hidden; position: relative;}

??????????#submitEditLanMu:hover,#backtolanmu:hover?{color: #27323A;}

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

?????????<div?id="editLanMuDiv"?style=" height:150px; border:0">

????????????<div?style=" text-align:center; color:White">編輯欄目</div>

????????????<div?class="addUserClass">

????????????????<asp:Label?ID="Label1"?Text="欄目名:"?runat="server"?/>

????????????????<asp:TextBox?ID="editLanMu"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>

????????????</div>

????????????<asp:Button?Text="確定"?runat="server"?ID="submitEditLanMu"?οnclick="submitEditLanMu_Click"?/>

????????????<asp:Button?ID="backtolanmu"?runat="server"?Text="返回"?οnclick="back_Click"?/>

????????</div>

????</div>

????</form>

</body>

</html>

?

欄目管理(lanmuManage.aspx):

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

<head?runat="server">

????<title></title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}

????????#addLanMu,#backtomanage

????????{

????????????color:White;

????????????width:100px;

????????????height: 35px;

????????outline: none;

????????margin:10px?50px;

????????border: none;

????????

????????line-height: 35px;

????????border-radius: 50px;

????????position: relative;

????????border: rgba(255,255,255,0.2)?2px?solid?;

????????color: var(--color);

????????????-webkit-transition: 0.25s;

????????????transition: 0.25s;

????????}

????????#addLanMu?{box-shadow: 0.3em?0.3em?0?0?var(--color),?inset?0.3em?0.3em?0?0?var(--color);}

????????#addLanMu:hover, #addLanMu:focus?{box-shadow: 0?0?0?0?var(--hover),?inset?6em?3.5em?0?0?var(--hover);}

????????#addLanMu?{--color: #19bc8b;--hover: #1973bc;}

????????#backtomanage:hover,#backtomanage:focus{box-shadow: inset?0?-3.25em?0?0?var(--hover);}

????????#backtomanage{ ?--color: #000000; ?--hover: #94e458;}

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????????<div?id="addLanMuHeader"?style=" height:50px; border:0">

????????????<div?style="float:left">

????????????????<asp:Label?ID="bigUser"?runat="server"></asp:Label>

????????????</div>

????????????<div?style="float:right">

????????????????<asp:Button?ID="addLanMu"?runat="server"?Text="添加欄目"?οnclick="addLanMu_Click"?/>

????????????</div>

????????</div>

????????<div?id="showLanMu">

????????????<div>

????????????????<asp:GridView?ID="gvLanMu"?runat="server"?AutoGenerateColumns="False"?

????????????????????Width="500px"?BorderStyle="None">

????????????????????<Columns>

????????????????????????<asp:BoundField?DataField="lanMuId"?HeaderText="欄目ID">

????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>

????????????????????????</asp:BoundField>

????????????????????????<asp:BoundField?DataField="lanMuName"?HeaderText="欄目名稱">

????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>

????????????????????????</asp:BoundField>

????????????????????????<asp:TemplateField?HeaderText="修改">

????????????????????????????<ItemTemplate>

????????????????????????????????<asp:LinkButton?ID="editLanMu"?runat="server"?οnclick="editLanMu_Click">編輯欄目</asp:LinkButton>

??????????????????????????????????

????????????????????????????????<asp:LinkButton?ID="delLanMu"?runat="server"?οnclick="delLanMu_Click">刪除</asp:LinkButton>

????????????????????????????</ItemTemplate>

????????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="150px"?BorderStyle="None"?/>

????????????????????????</asp:TemplateField>

????????????????????????<asp:TemplateField?HeaderText="管理">

????????????????????????????<ItemTemplate>

????????????????????????????????<asp:LinkButton?ID="setManage"?runat="server"?οnclick="setManage_Click">設置管理員</asp:LinkButton>

????????????????????????????</ItemTemplate>

????????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>

????????????????????????</asp:TemplateField>

????????????????????</Columns>

????????????????</asp:GridView>

????????????</div>

????</div>

????????<asp:Button?ID="backtomanage"?runat="server"?οnclick="backtomanage_Click"?Text="返回"?style=" float:right; position:absolute; right:110px"?/>

????</form>

????<div?id="backfooter">

????????<div?>

????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>

????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>

????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]

????????</div>

????</div>

</body>

</html>

5.1.2用戶部分

添加用戶(addUsers.aspx):

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

<head?runat="server">

????<title></title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

???????html,body?{padding:0;margin:0}

???????canvas?{ display:block}

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

????????<div?id="addUserDiv">

????????????<div?style=" text-align:center; color:White; ">增加用戶</div>

????????????<div?class="addUserClass">

????????????????<img?src="loginimages/user_icon_copy.png"?/>

????????????????<asp:TextBox?ID="addUserName"?runat="server"?style="width:150px; ?border:0px; color: White;"></asp:TextBox>

????????????</div>

????????????<br?/>

????????????<div?class="addUserClass">

????????????????<img?src="loginimages/lock_icon_copy.png"?/>

?????????????????<asp:TextBox?ID="addUserPwd"?runat="server"?style="width:150px; border:0px; color: White;"></asp:TextBox>

????????????</div>

????????????<div?class="mb2">

????????????????<asp:Button??Text="確定¨"?runat="server"?ID="submitUser"?οnclick="submitUser_Click"?/>

????????????</div>

????????????<div?class="mb2">

????????????????<asp:Button?ID="back"?runat="server"?οnclick="back_Click"?Text="返回"?/>

????????????</div>

????????</div>

????</div>

????</form>

????<canvas></canvas>

????<script?src="loginJavascript/hailang.js"?type="text/javascript"></script>

</body>

</html>

編輯用戶(editUsers.aspx):

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

<head?runat="server">

????<title></title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

?????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}

?????????#backto,#submitEditUser

?????????{

??????????????margin: 30px?20px;

??????????????padding: 15px?20px;

??????????????border-radius: 10px;

??????????????border: 2px?solid;

??????????????font: 16px?'Open Sans',?sans-serif;

??????????????text-transform: uppercase;

??????????????background: none;

??????????????outline: none;

??????????????cursor: pointer;

??????????????-webkit-transition: all?.5s;

??????????????transition: all?.5s;

??????????}

??????????#submitEditUser?{

??????????????color: #A3F7BF;

??????????????border-color: #A3F7BF;

??????????????background: -webkit-linear-gradient(left, #a3f7bf, #a3f7bf)?no-repeat;

??????????????background: linear-gradient(to right, #a3f7bf, #a3f7bf)?no-repeat;

??????????????background-size: 0%?100%;

????????????}

??????????#submitEditUser:hover?{background-size: 100%?100%; color: #27323A;}

??????????#backto?{color: #E4F68F;

??????????????border-color: #E4F68F;

??????????????background: -webkit-linear-gradient(left, #e4f68f, #e4f68f)?no-repeat;

??????????????background: linear-gradient(to right, #e4f68f, #e4f68f)?no-repeat;

??????????????background-size: 100%?0%;

????????????}

??????????#backto:hover?{background-size: 100%?100%; color: #27323A;}

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

?????????<div?id="editUserDiv">

????????????<div?style=" text-align:center; color:White;">編輯用戶</div>

????????????<div?class="addUserClass">

????????????????<img?src="loginimages/user_icon_copy.png"?/>

????????????????<asp:TextBox?ID="editUserName"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>

????????????</div>

????????????<br?/>

????????????<div?class="addUserClass">

????????????????<img?src="loginimages/lock_icon_copy.png"?/>

????????????????<asp:TextBox?ID="editUserPwd"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>

????????????</div>

????????????<asp:Button?Text="確定¨"?runat="server"?ID="submitEditUser"?οnclick="submitEditUser_Click"/>

????????????<asp:Button?ID="backto"?runat="server"?οnclick="back_Click"?Text="返回"?/>

????????</div>

????</div>

????</form>

</body>

</html>

管理用戶(userManage.aspx):

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

<head?runat="server">

????<title>用戶管理系統</title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

????????body{ background-image:url('backgroundimgs/bg003.jpg'); background-size: cover;}

????????#Button1

????????{

???????????color:White;

????????????width:100px;

????????????height: 35px;

????????outline: none;

????????margin:10px?50px;

????????border: none;

????????

????????line-height: 35px;

????????border-radius: 50px;

????????position: relative;

????????border: rgba(255,255,255,0.2)?2px?solid?;

????????color: var(--color);

????????????-webkit-transition: 0.25s;

????????????transition: 0.25s;

????????}

????????#Button1:hover,#Button1:focus?{box-shadow: inset?6.5em?0?0?0?var(--hover);}

????????#Button1?{--color: #8fc866;--hover: #66c887;}

????????#back:hover{ color:Black; ">????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

????????<div?id="addUserHeader"?style=" height:50px; border:0">

????????????<div?style="float:left">

????????????????<asp:Label?ID="bigUser"?runat="server"?style=" color:White;"></asp:Label>

????????????</div>

????????????<div?style="float:right">

????????????????<asp:Button?ID="Button1"?runat="server"?οnclick="Button1_Click"?Text="添加用戶"?/>

????????????</div>

????????</div>

????</div>

????<div?id="showUser">

????????????<asp:GridView?ID="gvUser"?runat="server"?AutoGenerateColumns="False"?

????????Width="1000px"?BorderStyle="None"??>

????????<Columns>

????????????<asp:BoundField?DataField="uid"?HeaderText="用戶編號">

????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>

????????????</asp:BoundField>

????????????<asp:HyperLinkField?DataNavigateUrlFields="uid"?DataTextField="userName"?

????????????????HeaderText="用戶姓名">

????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>

????????????</asp:HyperLinkField>

????????????<asp:BoundField?DataField="passWord"?HeaderText="用戶密碼">

????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>

????????????</asp:BoundField>

????????????<asp:TemplateField?HeaderText="修改">

????????????????<ItemTemplate>??

????????????????????<asp:LinkButton?ID="editUser"?runat="server"?οnclick="editUser_Click">編輯用戶</asp:LinkButton>

??????????????????????

????????????????????<asp:LinkButton?ID="deleteUser"?runat="server"?οnclick="deleteUser_Click">刪除</asp:LinkButton>

????????????????</ItemTemplate>

????????????????<ItemStyle?Width="200px"?HorizontalAlign="Center"?BorderStyle="None"?/>

????????????</asp:TemplateField>

????????</Columns>

????</asp:GridView>

????</div>

????<asp:Button?ID="back"?runat="server"?οnclick="back_Click"?Text="返回"?style=" position:absolute; right:50px;"/>

????</form>

????<div?id="backfooter">

????????<div?>

????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>

????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>

????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]

????????</div>

????</div>

</body>

</html>

5.1.3新聞部分

添加新聞(addNews.aspx):

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

<head?runat="server">

????<title>發布信息頁面</title>

????<style?type="text/css">

?????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}

????</style>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

?????<link?rel="stylesheet"?href="kde/themes/default/default.css"?/>

<link?rel="stylesheet"?href="kde/plugins/code/prettify.css"?/>

<script?charset="utf-8"?src="kde/kindeditor.js"></script>

<script?charset="utf-8"?src="kde/lang/zh_CN.js"></script>

<script?charset="utf-8"?src="kde/plugins/code/prettify.js"></script>

<script>

????KindEditor.ready(function?(K) {

????????var?editor1 = K.create('#content1', {

????????????cssPath: 'kde/plugins/code/prettify.css',

????????????uploadJson: 'kde/upload_json.ashx',

????????????fileManagerJson: 'kde/file_manager_json.ashx',

????????????allowFileManager: true,

????????????afterCreate: function?() {

????????????????var?self = this;

????????????????K.ctrl(document, 13, function?() {

????????????????????self.sync();

????????????????????K('form[name=example]')[0].submit();

????????????????});

????????????????K.ctrl(self.edit.doc, 13, function?() {

????????????????????self.sync();

????????????????????K('form[name=example]')[0].submit();

????????????????});

????????????}

????????});

????????prettyPrint();

????});

</script>

</head>

<body>

????<form?id="example"?runat="server">

????<div?id="box">

????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">標題:<asp:TextBox?

????????????????ID="txtTitle"?runat="server"></asp:TextBox>

????????</div>

????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">欄目:<asp:DropDownList?

????????????????ID="ddlLanMu"?runat="server">

????????????</asp:DropDownList>

??????????主頁圖片:<asp:TextBox?ID="txtImgUrl"?runat="server"?Width="495px"></asp:TextBox>

????????</div>

????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">

????????????<textarea?id="content1"?cols="100"?rows="8"?style="width:1000px;height:500px;visibility:hidden;"?runat="server"></textarea>

????????????<br?/>

????????????<asp:Button?ID="btnBack"?runat="server"?οnclick="btnBack_Click"?Text="返回"?/>

?<asp:Button?ID="btnSubmit"?runat="server"?Text="提交內容"?

????????????????οnclick="btnSubmit_Click"?/>?(提交快捷鍵: Ctrl + Enter)

????????</div>

????</div>

????</form>

</body>

</html>

編輯新聞(editNews.aspx):

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

<head?id="Head1"?runat="server">

????<title>編輯新聞頁面</title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

?????<link?rel="stylesheet"?href="kde/themes/default/default.css"?/>

<link?rel="stylesheet"?href="kde/plugins/code/prettify.css"?/>

<script?charset="utf-8"?src="kde/kindeditor.js"></script>

<script?charset="utf-8"?src="kde/lang/zh_CN.js"></script>

<script?charset="utf-8"?src="kde/plugins/code/prettify.js"></script>

<script>

????KindEditor.ready(function?(K) {

????????var?editor1 = K.create('#content1', {

????????????cssPath: 'kde/plugins/code/prettify.css',

????????????uploadJson: 'kde/upload_json.ashx',

????????????fileManagerJson: 'kde/file_manager_json.ashx',

????????????allowFileManager: true,

????????????afterCreate: function?() {

????????????????var?self = this;

????????????????K.ctrl(document, 13, function?() {

????????????????????self.sync();

????????????????????K('form[name=example]')[0].submit();

????????????????});

????????????????K.ctrl(self.edit.doc, 13, function?() {

????????????????????self.sync();

????????????????????K('form[name=example]')[0].submit();

????????????????});

????????????}

????????});

????????prettyPrint();

????});

</script>

</head>

<body>

????<form?id="example"?runat="server">

????<div?id="box">

????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">標題:<asp:TextBox?

????????????????ID="txtTitle"?runat="server"></asp:TextBox>

????????</div>

????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">欄目:<asp:DropDownList?

????????????????ID="ddlLanMu"?runat="server">

????????????</asp:DropDownList>

??????????主頁圖片:<asp:TextBox?ID="txtImgUrl"?runat="server"?Width="475px"></asp:TextBox>

????????</div>

????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">

????????????<textarea?id="content1"?cols="100"?rows="8"?style="width:1000px;height:500px;visibility:hidden;"?runat="server"></textarea>

????????????<br?/>

????????????<asp:Button?ID="btnCancel"?runat="server"?οnclick="btnCancel_Click"?Text="返回"?/>

?<asp:Button?ID="btnEdit"?runat="server"?Text="提交內容"?οnclick="btnEdit_Click"?/>?(提交快捷鍵: Ctrl + Enter)

????????</div>

????</div>

????</form>

</body>

</html>

?

給新聞設置管理員:(setManage.aspx

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

<head?runat="server">

????<title></title>

????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

????????????body{ background-image:url('backgroundimgs/bg003.jpg');}

????????????#setManage,#backTo

????????????{

??????????????margin?: 30px?20px;

??????????????padding: 15px?20px;

??????????????border-radius: 10px;

??????????????border: 2px?solid;

??????????????font: 16px?'Open Sans',?sans-serif;

??????????????text-transform: uppercase;

??????????????background: none;

??????????????outline: none;

??????????????cursor: pointer;

??????????????-webkit-transition: all?.5s;

??????????????transition: all?.5s;}

???????????????#setManage??{color: #A3F7BF;

??????????????border-color: #A3F7BF;

??????????????background: -webkit-linear-gradient(left, #a3f7bf, #a3f7bf)?no-repeat;

??????????????background: linear-gradient(to right, #a3f7bf, #a3f7bf)?no-repeat;

??????????????background-size: 0%?100%;}

?????????????#setManage:hover?{background-size: 100%?100%; color: #27323A;}

?????????????#backTo{color: #E4F68F;

??????????????border-color: #E4F68F;

??????????????background: -webkit-linear-gradient(left, #e4f68f, #e4f68f)?no-repeat;

??????????????background: linear-gradient(to right, #e4f68f, #e4f68f)?no-repeat;

??????????????background-size: 100%?0%;}

?????????????#backTo:hover,#backTo:focus?{background-size: 100%?100%; color: #27323A;} ???????????

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

????????<div?id="manageList">

?????????????<div?style=" text-align:center; color:White;">設置管理員</div></br>

?????????????<asp:DropDownList?ID="userList"?runat="server"?style="width:100px; height:30px ">

?????????????</asp:DropDownList>

?????????????</br>

?????????????<asp:Button?ID="setManage"?runat="server"?οnclick="setManage_Click"?Text="確認"?/>

?????????????<asp:Button?ID="backTo"?runat="server"?οnclick="back_Click"?Text="返回"?/>

????????</div>

????</div>

????</form>

????<div?id="backfooter">

????????<div?>

????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>

????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>

????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]

????????</div>

????</div>

</body>

</html>

?

新聞搜索(Search.aspx):

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

<head?runat="server">

????<title></title>

????<link?href="css/style.css"?rel="stylesheet"?type="text/css"?/>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

????????<div?id="box">

????????<div?id="header"></div>

????????<div?class="splitDiv"></div>

????????<div?id="showLanmu">

?????????????<%=Lanmu.getLanMu()%>

????????</div>

????????<div?class="splitDiv"></div>

????????<div?id="main">

????????????<div?id="left"?style="width:400px;">

????????????????

????????????????<asp:GridView?ID="SearchHotNews"?runat="server"?AutoGenerateColumns="False"?

????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?

????????????????????Width="400px">

????????????????????<Columns>

????????????????????????<asp:HyperLinkField?

????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?

????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">

????????????????????????<ItemStyle?Width="420px"?/>

????????????????????????</asp:HyperLinkField>

????????????????????????<asp:BoundField?DataField="hitCount"?HeaderText="點擊量">

????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="50px"?/>

????????????????????????</asp:BoundField>

????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}"?

????????????????????????????HeaderText="發布時間?">

????????????????????????<ItemStyle?Width="120px"?HorizontalAlign="Center"?/>

????????????????????????</asp:BoundField>

????????????????????</Columns>

????????????????</asp:GridView>

????????????</div>

????????????<div?id="right"?style="width:580px;">

????????????????<asp:GridView?ID="SearchNews"?runat="server"?AutoGenerateColumns="False"?

????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?

????????????????????Width="580px">

????????????????????<Columns>

????????????????????????<asp:HyperLinkField?

????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?

????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">

????????????????????????<ItemStyle?Width="420px"?/>

????????????????????????</asp:HyperLinkField>

????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}">

????????????????????????<ItemStyle?Width="100px"?HorizontalAlign="Center"?/>

????????????????????????</asp:BoundField>

????????????????????</Columns>

????????????????</asp:GridView>

????????????</div>

????????<div?class="splitDiv"></div>

????????<div?id="divLinks">友情鏈接</div>

????????<span?id="QLinks">

??????????????<ul?style=" border:1px solid #ccc; ?margin-top:10px; height:70px">

????????????????<li><a?href='http://rsc.cslg.cn/rsc/'?target='_blank'><img?src="yf/backgroundimgs/rsc.jpg"??border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://www.hep.com.cn/service/xuanshu'?target='_blank'><img?src='yf/backgroundimgs/gdjycbs.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://kjc.cslg.edu.cn/'?target='_blank'><img?src='yf/backgroundimgs/kxjs.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://jwc.cslg.cn/jwc/'?target='_blank'><img?src='yf/backgroundimgs/jwc.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://www.icourses.cn/'?target='_blank'><img?src='yf/backgroundimgs/akc.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://ctl.nju.edu.cn/yanjiuhui/'?target='_blank'><img?src='yf/backgroundimgs/jsgx.jpg'?border='0'?width='106px'?height='46px'></a></li>

??????????????</ul>

?????????</span>

?????????<div?class="splitDiv"></div>

????????<a?href="#top"><img?src="images/backTop.png"?alt="Alternate Text"?id="backTop"?title="回到頂部"?/></a>

????????<div?id="footer">

????????<div?>

????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>

????????????????聯系電話:188xxxxxxxx 郵政編括碼:215500 <br?/>

????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]

????????</div>

????</div>

????</form>

</body>

</html>

?

菜單欄目新聞(showlist.aspx):

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

<head?runat="server">

????<title></title>

????<link?href="css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

????????#sure{color:White;

????????????width:100px;

????????????height: 43px;

????????outline: none;

????????border: none;

????????line-height: 43px;

????????border-radius: 50px;

????????position: relative;

????????border: rgba(255,255,255,0.2)?2px?solid?;

????????color: var(--color);

????????????-webkit-transition: 0.25s;

????????????transition: 0.25s;

????????????}

????????#sure:hover,#sure:focus?{-webkit-animation: pulse?1s;animation: pulse?1s;box-shadow: 0?0?0?2em?rgba(255, 255, 255, 0);}

????????#sure?{--color: #ef6eae;--hover: #ef8f6e;}

????????@-webkit-keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}

????????@keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}

??????</style>

</head>

<body>

????<form?id="form1"?runat="server">

????<div>

????????<div?id="box">

????????<div?id="header"></div>

????????<div?class="splitDiv"></div>

????????<div?id="showLanmu">

?????????????<%=Lanmu.getLanMu()%>

?????????????<asp:Button?ID="sure"?runat="server"?Text="搜索"?/>

?????????????<asp:TextBox?ID="Search"?runat="server"??style="width:200px; border:1px solid ?black; border-radius: 50px; text-align:center"></asp:TextBox>

????????</div>

????????<div?class="splitDiv"></div>

????????<div?id="main">

????????????<div?id="left"?style="width:400px; ">

????????????????<asp:GridView?ID="gvHotNews"?runat="server"?AutoGenerateColumns="False"?

????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?

????????????????????Width="400px">

????????????????????<Columns>

????????????????????????<asp:HyperLinkField?

????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?

????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">

????????????????????????<ItemStyle?Width="420px"?/>

????????????????????????</asp:HyperLinkField>

????????????????????????<asp:BoundField?DataField="hitCount"?HeaderText="點擊量">

????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="50px"?/>

????????????????????????</asp:BoundField>

????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}"?

????????????????????????????HeaderText="發布時間?">

????????????????????????<ItemStyle?Width="120px"?HorizontalAlign="Center"?/>

????????????????????????</asp:BoundField>

????????????????????</Columns>

????????????????</asp:GridView>

????????????</div>

????????????<div?id="right"?style="width:580px; ">

????????????????<asp:GridView?ID="gvNews"?runat="server"?AutoGenerateColumns="False"?

????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?

????????????????????Width="580px">

????????????????????<Columns>

????????????????????????<asp:HyperLinkField?

????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?

????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">

????????????????????????<ItemStyle?Width="420px"?/>

????????????????????????</asp:HyperLinkField>

????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}">

????????????????????????<ItemStyle?Width="100px"?HorizontalAlign="Center"?/>

????????????????????????</asp:BoundField>

????????????????????</Columns>

????????????????</asp:GridView>

????????????</div>

????????<div?class="splitDiv"></div>

????????<div?id="divLinks">友情鏈接</div>

????????<span?id="QLinks">

??????????????<ul?style=" border:1px solid #ccc; ?margin-top:10px; height:70px">

????????????????<li><a?href='http://rsc.cslg.cn/rsc/'?target='_blank'><img?src="yf/backgroundimgs/rsc.jpg"??border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://www.hep.com.cn/service/xuanshu'?target='_blank'><img?src='yf/backgroundimgs/gdjycbs.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://kjc.cslg.edu.cn/'?target='_blank'><img?src='yf/backgroundimgs/kxjs.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://jwc.cslg.cn/jwc/'?target='_blank'><img?src='yf/backgroundimgs/jwc.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://www.icourses.cn/'?target='_blank'><img?src='yf/backgroundimgs/akc.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://ctl.nju.edu.cn/yanjiuhui/'?target='_blank'><img?src='yf/backgroundimgs/jsgx.jpg'?border='0'?width='106px'?height='46px'></a></li>

??????????????</ul>

?????????</span>

?????????<div?class="splitDiv"></div>

???????????

????????<a?href="#top"><img?src="images/backTop.png"?alt="Alternate Text"?id="backTop"?title="回到頂部"?/></a>

????????<div?id="footer">

????????<div?>

????????????????版權所有:@ 2018 姚鋒?地址:江蘇省常熟市南三環路99號 <br?/>

????????????????聯系電話:188xxxxxxxx 郵政編括碼:215500 <br?/>

????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]

????????</div>

????</div>

????</form>

</body>

</html>

?

單篇新聞(shownews.aspx:

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

<head?runat="server">

????<title>查看新聞頁面</title>

????<link?href="css/style.css"?rel="stylesheet"?type="text/css"?/>

????<style?type="text/css">

????????#shownewssure{color:White;

????????????width:100px;

????????????height: 43px;

????????outline: none;

????????line-height: 43px;

????????border-radius: 50px;

????????border: ?1px?solid?#000;

????????position: relative;

????????border: rgba(255,255,255,0.2)?2px?solid?;

????????color: var(--color);

????????????-webkit-transition: 0.25s;

????????????transition: 0.25s;

????????????}

????????#shownewssure:hover,#shownewssure:focus?{-webkit-animation: pulse?1s;animation: pulse?1s;box-shadow: 0?0?0?2em?rgba(255, 255, 255, 0);}

????????#shownewssure?{--color: #ef6eae;--hover: #ef8f6e;}

????????@-webkit-keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}

????????@keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}

????</style>

</head>

<body>

????<form?id="form1"?runat="server">

???<div?id="box">

????????<div?id="header"></div>

????????<div?class="splitDiv"></div>

????????<div?id="showLanmu">

????????????<div?id="lanMuList"?>

????????????????<%=Lanmu.getLanMu()%>

????????????????<asp:Button?ID="shownewssure"?runat="server"?Text="搜索"?

????????????????????οnclick="shownewssure_Click"?/>

????????????????<asp:TextBox?ID="shownewsSearch"?runat="server"?style="width:200px; border:1px solid ?black; border-radius: 50px; text-align:center"></asp:TextBox>

?????????????????

????????????</div>

????????</div>

????????<div?class="splitDiv"></div>

?

????????<div?id="main">

????????????<div?id="newsTitle">

????????????????<asp:Label?ID="lblTitle"?runat="server"></asp:Label>

????????????</div>

????????????<div?class="line"></div>

????????????<div?id="newsInfo">

????????????????<asp:Label?ID="lblAddTime"?runat="server"></asp:Label>

????????

????????????????<asp:Label?ID="lblHitCount"?runat="server"></asp:Label>

???????????

????????????????<asp:Label?ID="lblAuthor"?runat="server"></asp:Label>

????????????</div>

????????????<div?id="newsContent">

????????????????<asp:Label?ID="lblContent"?runat="server"></asp:Label>

????????????</div>

????????<div?class="splitDiv"></div>

????????<div?id="divLinks">友情鏈接</div>

????????<span?id="QLinks">

??????????????<ul?style=" border:1px solid #ccc; ?margin-top:10px; height:70px">

????????????????<li><a?href='http://rsc.cslg.cn/rsc/'?target='_blank'><img?src="yf/backgroundimgs/rsc.jpg"??border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://www.hep.com.cn/service/xuanshu'?target='_blank'><img?src='yf/backgroundimgs/gdjycbs.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://kjc.cslg.edu.cn/'?target='_blank'><img?src='yf/backgroundimgs/kxjs.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://jwc.cslg.cn/jwc/'?target='_blank'><img?src='yf/backgroundimgs/jwc.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://www.icourses.cn/'?target='_blank'><img?src='yf/backgroundimgs/akc.jpg'?border='0'?width='106px'?height='46px'></a></li>

????????????????<li><a?href='http://ctl.nju.edu.cn/yanjiuhui/'?target='_blank'><img?src='yf/backgroundimgs/jsgx.jpg'?border='0'?width='106px'?height='46px'></a></li>

??????????????</ul>

?????????</span>

?????????<div?class="splitDiv"></div>

????????<a?href="#top"><img?src="images/backTop.png"?alt="Alternate Text"?id="backTop"?title="回到頂部"?/></a>

????????<div?id="footer">

????????<div?>

????????????????版權所有:@ 2018 姚鋒地址:江蘇省常熟市南三環路99號<br?/>

????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>

????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]

????????</div>

????</div>

????</form>

</body>

</html>

5.1.4 主要CSS樣式部分

*,td,li,ul,body?{margin:0;padding:0; }

td,th,table{ border:o;}

#box{width:1000px;margin:0?auto;}

#header{width:1000px;height:170px; background-image:url(../images/toppic.jpg);}

#main{width:1000px;}

#left{float:left;width:490px;height:300px;}

#right{float:right;width:500px;}

.splitDiv{ height:10px; clear:both;}

.line{ width:1000px; height:1px; background:#000; margin:10px?0;}

#divLeft,#divMiddle,#divRight{width:320px;height:200px;float:left;}

#divRight{margin: 10px?10px?10px?0px; ?}

#divMiddle{ margin:10px?10px?10px?0px;}

#divLeft{ margin:10px?10px?10px?0px;}

#divLinks{ width:990px; border:1px?solid?#ccc; padding:5px;}

#footer{ width:1000px; text-align:center; ? font-size:14px; }

#backfooter{ ?width:100%; text-align:center; ?background-color:#20B2AA; font-size:14px; position:fixed; bottom:0px}

.smallTitle{ text-align:center;}

#backTop{ position:fixed; right:20px; bottom:15px;height: 154px;}

#lanMuList{ height:30px; width:1000px; }

#lanMuList?li{ list-style:none; float:left; margin: 0?5px?0px?0px; width:60px; height:40px; line-height:40px; ?text-align:center; }

#lanMuList?a{ text-decoration: none; color:White; font-weight:bold;}

#lanMuList?li:hover{ }

/*下面為showlist界面導航css樣式*/

#showLanmu?a:hover{ color:Red;}

#showLanmu{ height:30px; width:1000px; }

#showLanmu?li{ list-style:none; float:left; margin: 0?5px?0px?0px; width:60px; height:40px; line-height:40px; ?text-align:center; }

#showLanmu?a{ text-decoration: none; color:White; font-weight:bold;}

#showLanmu?li:hover{ }

#showLanmu?a:hover{ color:Red;}

/*下面為搜索框及按鈕css樣式*/

#sure,#shownewssure{ float:right; height:35px; width:50px;}

#Search,#shownewsSearch{ float:right; width:200px; height:30px; }

#QLinks?ul?li{ list-style-type:none;float:left; height:60px; width:157px; margin:8px?0?0?8px; *display:inline; overflow:hidden;}

#QLinks?ul?li?img{ width:149px; height:52px; padding:3px; border:1px?solid?#e6e6e6;}

?/*下面是登陸界面的css樣式表*/

#userlogin{width:150px;height:90px;position:absolute;

?????left:50%;top:50%;

?????border:1px?red?solid;

?????margin-left:-75px;

?????margin-top:-45px;}

?/*下面是查看新聞內容頁面的樣式表*/

#newsTitle{width:1000px;text-align:center;font-size:18pt;}

#newsContent{width:1000px;font-size:12pt;}

#newsInfo{ width:1000px; font-size:12pt; text-align:center; margin-bottom:10px;}

/*下面是管理頁面布局樣式表*/

#adminHeader{ line-height:25px; height:25px; width:1000px; margin-top:5px;}

#adminMenu{line-height:25px;height:25px;width:1000px;}

#adminContent{width:1000px;}

/*下面是用戶管理界面樣式表*/

#showUser{ width:1000px; margin:0?auto;}

/*下面是增加用戶樣式表*/

#addUserDiv?

{width:250px; position:absolute; top:50%;left:50%; ?text-align:center;

?box-shadow: -15px?15px?15px?rgba(6, 17, 47, 0.7);opacity: 1;top: 20px;

?position: relative;width: 300px;height: 400px;position: absolute;

?left: 0;right: 0;margin: auto;top: 0;bottom: 0;padding: 100px?40px?40px?40px;

?background: #35394a;

?/* Old browsers */

?/* FF3.6+ */

?background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, #35394a), color-stop(100%, rgb(0, 0, 0)));

?/* Chrome,Safari4+ */

?background: -webkit-linear-gradient(230deg, rgba(53, 57, 74, 0) 0%, rgb(0, 0, 0) 100%);

?/* Chrome10+,Safari5.1+ */

?/* Opera 11.10+ */

?/* IE10+ */

?background: linear-gradient(230deg, rgba(53, 57, 74, 0) 0%, rgb(0, 0, 0) 100%);

?/* W3C */

?filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='rgba(53, 57, 74, 0)', endColorstr='rgb(0, 0, 0)',GradientType=1 );

?/* IE6-9 fallback on horizontal gradient */}

.addUserClass?

{margin:20px;color:White;height: 46px;outline: none;margin-left: 50px;border: none;line-height: 46px;height: 46px;padding: 0?5px;margin-bottom: 20px;border-radius: 50px;position: relative;border: rgba(255,255,255,0.2)?2px?solid?;}

.mb2?#back,#submitUser{text-decoration: none;outline: none;}

#back,#submitUser?{padding: 15px;margin-left:30px;float:left;display: block;line-height: 20px;text-align: center;font-size: 20px;border-radius: 50px;background: ?rgba(0,0,0,0);border:1px?solid?#75faff;width:100px;color:#75faff;}

#addUserName,#addUserPwd,#editUserName,#editUserPwd,#editLanMu,#addLanMuName,#Search,#shownewsSearch{height: 40px;outline: none;margin-left: 20px;border: none;line-height: 40px;color: black;}

#addUserHeader{line-height:25px; height:25px; width:1000px; margin:5px?auto; border:1px?solid?#ccc;}

/*下面是編輯用戶樣式表*/

#editUserDiv{ width:250px; position:absolute; top:50%;left:50%; margin-left:-155px; margin-top:-200px; text-align:center; background: rgba(41, 39, 39, 0.46);-webkit-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);-moz-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);box-shadow: 0px?35px?44px?-22px?#1f181b;padding: 60px?40px; }

.addUserClass{ margin:20px;}

#eidtUserHeader{line-height:25px; height:25px; width:1000px; margin:5px?auto; border:1px?solid?#ccc;}

/*下面是欄目管理界面樣式表*/

#showLanMu{ width:1000px; margin:0?auto;}

#addLanMuHeader{line-height:25px; height:25px; width:1000px; margin:5px?auto; border:1px?solid?#ccc;}

#editLanMuDiv,#addLanMuDiv,#manageList{width:300px; position:absolute; top:50%;left:50%; margin-left:-155px; margin-top:-200px;

??????????????text-align:center; background: rgba(41, 39, 39, 0.46);

??????????????-webkit-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);-moz-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);

??????????????box-shadow: 0px?35px?44px?-22px?#1f181b;

??????????????padding: 60px?40px;}

?

5.2后臺部分主要代碼

5.2.1數據庫部分

Sqlhelper類:

public?class?sqlhelper

{

public?sqlhelper()

{

}

????///?<summary>

????///?函數實現建數據庫連接,并返回該連接

????///?</summary>

????///?<returns>返回建立好的數據庫連接</returns>

????public?static?SqlConnection?createCon()

????{

????????//獲取配置文件中設置好的連接

????????SqlConnection?con = new?SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myCon"].ConnectionString);

????????return?con;

????}

????public?static?void?excuteSql(string?sqlString)

????{

????????SqlConnection?con = createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString, con);

????????cmd.ExecuteNonQuery();

????????con.Close();

????}

????///?<summary>

????///?數據檢索

????///?</summary>

????///?<param name="sqlString"></param>

????///?<returns></returns>

????public?static?DataSet?excuteDataSet(string?sqlString)

????{

????????SqlConnection?con = createCon();

????????con.Open();

????????SqlDataAdapter?sda = new?SqlDataAdapter(sqlString, con);

????????DataSet?ds = new?DataSet();

????????sda.Fill(ds);

????????con.Close();

????????return?ds;

????}

????public?static?int?excuteInt(string?sqlString)

????{

????????SqlConnection?con = createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString,con);

????????int?count=0;

????????count = Convert.ToInt32(cmd.ExecuteScalar());

????????con.Close();

????????return?count;

????}

????public?static?bool?excuteBool(string?sqlString)

????{

????????SqlConnection?con = createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString, con);

????????bool?result = true;

????????try?

????????{

????????????cmd.ExecuteNonQuery();

????????}

????????catch

????????{

????????????result=false;

????????}

????????con.Close();

????????return?result;

????}

????public?static?SqlDataReader?ExcuteSqlDataReader(string?sql, SqlParameter[] parms)

????{

????????SqlDataReader?result = null;

????????SqlConnection?con = createCon();

????????try

????????{

????????????con.Open();

????????????SqlCommand?cmd = new?SqlCommand(sql, con);

????????????if?(parms != null)

????????????????cmd.Parameters.AddRange(parms);

????????????result = cmd.ExecuteReader(CommandBehavior.CloseConnection);

????????}

????????catch

????????{ }

????????return?result;

????}

}

public?static?News?getNewsById(string?id)//通過新聞id查找新聞????

{

????????News?news = new?News();

????????string?sqlString="select * from t_news where newid="+id;

????????SqlConnection?con = sqlhelper.createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString,con);

????????SqlDataReader?sdr = cmd.ExecuteReader();

????????while?(sdr.Read())

????????{

????????????news.newid = Convert.ToInt32(sdr[0]);

????????????news.title = Convert.ToString(sdr[1]);

????????????news.contents = Convert.ToString(sdr[2]);

????????????news.newid = Convert.ToInt32(sdr[3]);

????????????news.addTime =Convert.ToDateTime(sdr[4]);

????????????news.lanMuId = Convert.ToInt32(sdr[5]);

????????????news.hitCount = Convert.ToInt32(sdr[6]);

????????}

????????con.Close();

????????return?news;

}

News類:

public?class?News

{

public?News()

{

}

????public?int?newid;

????public?string?title;

????public?string?contents;

????public?int?uid;

????public?DateTime?addTime;

????public?int?lanMuId;

????public?int?hitCount;

????public?string?img;

????public?static?void?getPics(ref?string?pics,ref?string?texts,ref?string?links)

????{

????????string?sqlString = "select top 5 newid,title,img from t_news where img<>'' order by addTime DESC";

????????SqlConnection?con = sqlhelper.createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString, con);

????????SqlDataReader?sdr = cmd.ExecuteReader();

????????while?(sdr.Read())

????????{

????????????pics += sdr[2].ToString()+"|";

????????????texts += sdr[1].ToString() + "|";

????????????links += "showNews.aspx?id="?+sdr[0].ToString()+ "|";

????????}

????????pics = pics.Substring(0, pics.Length - 1);

????????texts = texts.Substring(0, texts.Length - 1);

????????links = links.Substring(0, links.Length - 1);

????}

????public?static?News?getNewsByText(string?text)

????{

????????News?news = new?News();

????????string?sqlString = "select * from news where title like ?'%"?+ text + "%' order by addTime DESC";

????????SqlConnection?con = sqlhelper.createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString, con);

????????SqlDataReader?sdr = cmd.ExecuteReader();

????????while?(sdr.Read())

????????{

????????????news.newid = Convert.ToInt32(sdr[0]);

????????????news.title = Convert.ToString(sdr[1]);

????????????news.contents = Convert.ToString(sdr[2]);

????????????news.newid = Convert.ToInt32(sdr[3]);

????????????news.addTime = Convert.ToDateTime(sdr[4]);

????????????news.lanMuId = Convert.ToInt32(sdr[5]);

????????????news.hitCount = Convert.ToInt32(sdr[6]);

????????}

????????con.Close();

????????return?news;

????}

????public?static?News?getNewsById(string?id)

????{

????????News?news = new?News();

????????string?sqlString="select * from t_news where newid="+id;

????????SqlConnection?con = sqlhelper.createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString,con);

????????SqlDataReader?sdr = cmd.ExecuteReader();

????????while?(sdr.Read())

????????{

????????????news.newid = Convert.ToInt32(sdr[0]);

????????????news.title = Convert.ToString(sdr[1]);

????????????news.contents = Convert.ToString(sdr[2]);

????????????news.newid = Convert.ToInt32(sdr[3]);

????????????news.addTime =Convert.ToDateTime(sdr[4]);

????????????news.lanMuId = Convert.ToInt32(sdr[5]);

????????????news.hitCount = Convert.ToInt32(sdr[6]);

????????}

????????con.Close();

????????return?news;

????}

????public?static?void?addHitCount(string?id)

????{

????????string?sqlString = "update t_news set hitCount=hitCount+1 where newid="+id;

????????sqlhelper.excuteSql(sqlString);

????}

????public?static?DataSet?getNewsList()

????{

????????string?sqlString = "select * from View_News order by addTime DESC";

????????return?sqlhelper.excuteDataSet(sqlString);

????}

????public?static?DataSet?getNewsBymanageId(string?id)//管理員管理的頁面顯示相應欄目的新聞

????{

????????string?sqlString = "select * from t_user,t_news,t_lanMu where t_user.manageLanmuid=t_news.lanMuId and t_news.lanMuId=t_lanMu.lanMuId and t_user.uid="+id;

????????return?sqlhelper.excuteDataSet(sqlString);

????}

????public?static?bool?addNews(News?n)

????{

????????string?sqlString = "insert into t_news (title,contents,uid,addTime,lanMuId,hitCount,img) values('"+n.title+"','"+n.contents+"',"+n.uid+",'"+n.addTime+"',"+n.lanMuId+","+n.hitCount+",'"+n.img+"')";

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?editNews(News?n)

????{

????????string?sqlString = "update t_news set title='"?+ n.title + "', contents='"?+ n.contents + "', uid="?+ n.uid + ", lanMuId="?+ n.lanMuId+",img='"+n.img+"' where newid="?+n.newid;

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?delNews(string?id)

????{

????????string?sqlString = "delete from t_news where newid="?+ id;

????????return?sqlhelper.excuteBool(sqlString);

????}

}

Users類:

public?class?Users

{

public?Users()

{

}

????public?int?uid;

????public?string?userName;

????public?string?passWord;

????public?int?manageLanmuid;

????public?static?Users?getUserById(string?id)

????{

????????Users?users = new?Users();

????????string?sqlString = "select * from t_user where uid="?+ id;

????????SqlConnection?con = sqlhelper.createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString, con);

????????SqlDataReader?sdr = cmd.ExecuteReader();

????????while?(sdr.Read())

????????{

????????????users.uid = Convert.ToInt32(sdr[0]);

????????????users.userName = Convert.ToString(sdr[1]);

????????????users.passWord = Convert.ToString(sdr[2]);

????????}

????????con.Close();

????????return?users;

????}

????public?static?int?getuidByName(string?userName)

????{

????????string?sqlString = "select uid from t_user where userName='"?+ userName + "'";

????????SqlConnection?con = sqlhelper.createCon();

????????con.Open();

????????SqlCommand?cmd = new?SqlCommand(sqlString, con);

????????int?uid = Convert.ToInt32(cmd.ExecuteScalar());

????????con.Close();

????????return?uid;

????}

????public?static?DataSet?getUserList()//獲取用戶列表

????{

????????string?sqlString = "select * from t_user";

????????return?sqlhelper.excuteDataSet(sqlString);

????}

????public?static?bool?delUser(string?id)

????{

????????string?sqlString = "delete from t_user where uid="?+ id;

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?addUser(Users?n)

????{

????????string?sqlString = "insert into t_user (userName,passWord) values('"?+ n.userName + "','"?+ n.passWord + "' )";

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?editUser(Users?n)

????{

????????string?sqlString = "update t_user set userName ='"?+ n.userName + "', passWord='"?+ n.passWord + "' ?where uid="?+ n.uid;

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?giveUseraddlanmu(Users?n)

????{

????????string?sqlString = "update t_user set userName ='"?+ n.userName + "', passWord='"?+ n.passWord + "', manageLanmuid='"?+ n.manageLanmuid + "' ?where uid="?+ n.uid;

????????return?sqlhelper.excuteBool(sqlString);

????}

}

Lanmu類:

public?class?Lanmu

{

public?Lanmu()

{

}

????public?int?lanMuId;

????public?string?lanMuName;

????public?static?DataSet?getLanMuList()//獲取用戶列表

????{

????????string?sqlString = "select * from t_lanMu";

????????return?sqlhelper.excuteDataSet(sqlString);

????}

????public?static?string?getLanMu()//獲取動態欄目

????{

????????string?result = "";

????????string?sql = "select * from t_lanMu";

????????System.Data.SqlClient.SqlDataReader?sdr = sqlhelper.ExcuteSqlDataReader(sql, null);

????????while?(sdr.Read())

????????{

????????????result += "<li><a href='showlist.aspx?id="?+ sdr["lanMuId"] + "'>";

????????????result += sdr["lanMuName"].ToString() + "</a>"?+ "</li>";

????????}

????????sdr.Close();

????????return?result;

????}

????public?static?bool?addLanMu(Lanmu?l)

????{

????????string?sqlString = "insert into t_lanMu (lanMuName) values('"?+ l.lanMuName + "')";

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?delLanMu(string?id)

????{

????????string?sqlString = "delete from t_lanMu where lanMuId="?+ id;

????????return?sqlhelper.excuteBool(sqlString);

????}

????public?static?bool?editLanMu(Lanmu?l)

????{

????????string?sqlString = "update t_lanMu set lanMuName='"?+ l.lanMuName + "' ?where lanMuId="?+ l.lanMuId;

????????return?sqlhelper.excuteBool(sqlString);

????}

}

5.2.2欄目部分

增加欄目(addLanMu.aspx.cs):

public?partial?class?yf_addNews?: System.Web.UI.Page

{

????Users?u;

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????{

????????????Response.Redirect("index.aspx");

????????}

????????else

????????{

????????????u=(Users)Session["user"];

????????}

????????if?(!IsPostBack)//防止沒有取到下拉菜單值

????????{

????????????ddlLanMu.DataSource = Lanmu.getLanMuList();

????????????ddlLanMu.DataTextField = "lanMuName";

????????????ddlLanMu.DataValueField = "lanMuId";

????????????ddlLanMu.DataBind();

????????????if?(Request.QueryString["id"] != null)

????????????{

????????????????string?id = Request.QueryString["id"].ToString();

????????????????News?n = News.getNewsById(id);

????????????????txtTitle.Text = n.title;

????????????????content1.Value = n.contents;

????????????????foreach?(ListItem?x in?ddlLanMu.Items)

????????????????{

????????????????????if?(x.Value == n.lanMuId.ToString())

????????????????????{

????????????????????????x.Selected = true;

????????????????????}

????????????????}

????????????}

????????}

????}

????protected?void?btnSubmit_Click(object?sender, EventArgs?e)

????{

????????News?n = new?News();

????????n.title = txtTitle.Text;

????????n.contents = content1.Value;

????????n.addTime = DateTime.Now;

????????n.hitCount = 0;

????????n.lanMuId =Convert.ToInt32(ddlLanMu.SelectedValue);

????????n.uid = u.uid;

????????n.img = txtImgUrl.Text;

????????if?(News.addNews(n)== true?)

????????????Response.Write("<script>alert('發布成功!')</script>");

????????else

????????????Response.Write("<script>alert('發布失敗!')</script>");

????}

????protected?void?btnBack_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("manage.aspx");

????}

}

編輯欄目(editLanMu.aspx.cs):

public?partial?class?yf_editLanMu?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????}

????protected?void?submitEditLanMu_Click(object?sender, EventArgs?e)

????{

????????Lanmu?l = new?Lanmu();

????????l.lanMuName = editLanMu.Text;

????????l.lanMuId = Convert.ToInt32(Request.QueryString["id"].ToString());

????????if?(Lanmu.editLanMu(l) == true)

????????????Response.Write("<script>alert('修改成功!')</script>");

????????else

????????????Response.Write("<script>alert('修改失敗!')</script>");

????}

????protected?void?back_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("lanmuManage.aspx");

????}

}

欄目管理(lanmuManage.aspx.cs):

public?partial?class?yf_LanMumanage?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????{

????????????Response.Write("<script>alert('您尚未登錄!')</script>");

????????????Response.Redirect("index.aspx");

????????}

????????else

????????{

????????????Users?u = (Users)Session["user"];

????????????bigUser.Text = "歡迎"?+ u.userName;

????????}

????????showLanMuList();

????}

?

????public?void?showLanMuList()

????{

????????gvLanMu.DataSource = Lanmu.getLanMuList();

????????gvLanMu.DataBind();

????}

????protected?void?delLanMu_Click(object?sender, EventArgs?e)

????{

????????LinkButton?btn = (LinkButton)sender;

????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;

????????string?id = gvr.Cells[0].Text;

????????if?(Lanmu.delLanMu(id) == true?&& (Convert.ToInt32(id) != 1))

????????{

????????????Response.Write("<script>alert('刪除成功!')</script>");

????????????showLanMuList();

????????}

????????else

????????????Response.Write("<script>alert('刪除失敗!')</script>");

????}

????protected?void?editLanMu_Click(object?sender, EventArgs?e)

????{

????????LinkButton?btn = (LinkButton)sender;

????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;

????????string?id = gvr.Cells[0].Text;

????????Response.Redirect("editLanMu.aspx?id="?+ id);

????}

????protected?void?addLanMu_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("addLanMu.aspx");

????}

????protected?void?backtomanage_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("manage.aspx");

????}

????protected?void?setManage_Click(object?sender, EventArgs?e)

????{

????????LinkButton?btn = (LinkButton)sender;

????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;

????????string?id = gvr.Cells[0].Text;

????????Response.Redirect("setManage.aspx?id="?+ id);

????}

}

5.2.3用戶部分

添加用戶(addUsers.aspx.cs):

public?partial?class?yf_addUser?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????}

????protected?void?submitUser_Click(object?sender, EventArgs?e)

????{

????????if?(addUserName.Text.Trim() == ""?|| addUserPwd.Text.Trim() == "")

????????{

????????????Response.Write("<script>alert('用戶名和密碼不能為空。');</script>");

????????}

????????else

????????{

????????????Users?n = new?Users();

????????????n.userName = addUserName.Text;

????????????n.passWord = addUserPwd.Text;

????????????if?(Users.addUser(n) == true)

????????????????Response.Write("<script>alert('添加成功')</script>");

????????????else

????????????????Response.Write("<script>alert('添加失敗')</script>");

????????}

????}

????protected?void?back_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("userManage.aspx");

????}

}

編輯用戶(editUsers.aspx.cs):

public?partial?class?yf_editUser?: System.Web.UI.Page

{

????Users?u;

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????????Response.Redirect("index.aspx");

????????else

????????????u = (Users)Session["user"];

????????if?(!IsPostBack)

????????{

????????????if?(Request.QueryString["id"] != null)

????????????{

????????????????string?id = Request.QueryString["id"].ToString();

????????????????Users?n = Users.getUserById(id);

????????????????editUserName.Text = n.userName;

????????????????editUserPwd.Text = n.passWord;

????????????}

????????}

????}

????protected?void?submitEditUser_Click(object?sender, EventArgs?e)

????{

????????Users?n = new?Users();

????????n.userName = editUserName.Text;

????????n.passWord = editUserPwd.Text;

????????n.uid = Convert.ToInt32(Request.QueryString["id"].ToString());

????????if?(Users.editUser(n) == true)

????????????Response.Write("<script>alert('修改成功')</script>");

????????else

????????????Response.Write("<script>alert('修改失敗')</script>");

????}

????protected?void?back_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("manage.aspx");

????}

}

管理用戶(userManage.aspx.cs):

public?partial?class?yf_userManage?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????{

????????????Response.Write("<script>alert('您尚未登錄')</script>");

????????????Response.Redirect("index.aspx");

????????}

????????else

????????{

????????????Users?u = (Users)Session["user"];

?????????????bigUser.Text = "歡迎"?+ u.userName;

????????}

????????showUserList();

????}

????public?void?showUserList()

????{

????????gvUser.DataSource = Users.getUserList();

????????gvUser.DataBind();

????}

????protected?void?editUser_Click(object?sender, EventArgs?e)

????{

????????LinkButton?btn = (LinkButton)sender;

????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;

????????string?id = gvr.Cells[0].Text;

????????Response.Redirect("editUser.aspx?id="?+ id);

????}

????protected?void?deleteUser_Click(object?sender, EventArgs?e)

????{

????????LinkButton?btn = (LinkButton)sender;

????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;

????????string?id = gvr.Cells[0].Text;

????????if?(Users.delUser(id) == true&&(Convert.ToInt32(id)!=1))

????????{

????????????Response.Write("<script>alert('刪除成功')</script>");

????????????showUserList();

????????}

????????else

????????{

????????????Response.Write("<script>alert('刪除失敗')</script>");

????????}

????}

????protected?void?Button1_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("addUser.aspx");

????}

????protected?void?back_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("manage.aspx");

????}

}

5.2.4新聞部分

添加新聞(addNews.aspx.cs):

public?partial?class?yf_addNews?: System.Web.UI.Page

{

????Users?u;

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????{

????????????Response.Redirect("index.aspx");

????????}

????????else

????????{

????????????u=(Users)Session["user"];

????????}

????????if?(!IsPostBack)

????????{

????????????ddlLanMu.DataSource = Lanmu.getLanMuList();

????????????ddlLanMu.DataTextField = "lanMuName";

????????????ddlLanMu.DataValueField = "lanMuId";

????????????ddlLanMu.DataBind();

????????????if?(Request.QueryString["id"] != null)

????????????{

????????????????string?id = Request.QueryString["id"].ToString();

????????????????News?n = News.getNewsById(id);

????????????????txtTitle.Text = n.title;

????????????????content1.Value = n.contents;

????????????????foreach?(ListItem?x in?ddlLanMu.Items)

????????????????{

????????????????????if?(x.Value == n.lanMuId.ToString())

????????????????????{

????????????????????????x.Selected = true;

????????????????????}

????????????????}

????????????}

????????}

????}

????protected?void?btnSubmit_Click(object?sender, EventArgs?e)

????{

????????News?n = new?News();

????????n.title = txtTitle.Text;

????????n.contents = content1.Value;

????????n.addTime = DateTime.Now;

????????n.hitCount = 0;

????????n.lanMuId =Convert.ToInt32(ddlLanMu.SelectedValue);

????????n.uid = u.uid;

????????n.img = txtImgUrl.Text;

????????if?(News.addNews(n)== true?)

????????????Response.Write("<script>alert('發布成功')</script>");

????????else

????????????Response.Write("<script>alert('發布失敗')</script>");

????}

????protected?void?btnBack_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("manage.aspx");

????}

}

編輯新聞(editNews.aspx.cs):

public?partial?class?yf_editeNews?: System.Web.UI.Page

{

????Users?u;

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????????Response.Redirect("index.aspx");

????????else

????????????u = (Users)Session["user"];

????????if?(!IsPostBack)

????????{

????????????ddlLanMu.DataSource = Lanmu.getLanMuList();

????????????ddlLanMu.DataTextField = "lanMuName";

????????????ddlLanMu.DataValueField = "lanMuId";

????????????ddlLanMu.DataBind();

????????????if?(Request.QueryString["id"] != null)

????????????{

????????????????string?id = Request.QueryString["id"].ToString();

????????????????News?n = News.getNewsById(id);

????????????????txtTitle.Text = n.title;

????????????????content1.Value = n.contents;

????????????????foreach?(ListItem?x in?ddlLanMu.Items)

????????????????{

????????????????????if?(x.Value == n.lanMuId.ToString())

????????????????????{

????????????????????????x.Selected = true;

????????????????????}

????????????????}

????????????}

????????}

????}

????protected?void?btnEdit_Click(object?sender, EventArgs?e)

????{

????????News?n = new?News();

????????n.title = txtTitle.Text;

????????n.contents = content1.Value;

????????n.uid = u.uid;

????????n.lanMuId =Convert.ToInt32(ddlLanMu.SelectedValue);

????????n.newid = Convert.ToInt32(Request.QueryString["id"].ToString());

????????n.img = txtImgUrl.Text;

????????if?(News.editNews(n)== true)

????????????Response.Write("<script>alert('修改成功')</script>");

????????else

????????????Response.Write("<script>alert('修改失敗')</script>");

????}

????protected?void?btnCancel_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("manage.aspx");

????}

}

給新聞設置管理員:(setManage.aspx.cs

public?partial?class?yf_setManage?: System.Web.UI.Page

{

????Users?u;

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Session["user"] == null)

????????{

????????????Response.Redirect("index.aspx");

????????}

????????else

????????{

????????????u = (Users)Session["user"];

????????}

????????if?(!IsPostBack)//防止沒有正確取到下拉菜單里的值

????????{

????????????userList.DataSource = Users.getUserList();

????????????userList.DataTextField = "userName";

????????????userList.DataValueField = "uid";

????????????userList.DataBind();

????????????if?(Request.QueryString["id"] != null)

????????????{

????????????????string?id = Request.QueryString["id"].ToString();

????????????????Users?n = Users.getUserById(id); ??????

????????????????foreach?(ListItem?x in?userList.Items)

????????????????{

????????????????????if?(x.Value == n.manageLanmuid.ToString())

????????????????????{

????????????????????????x.Selected = true;

????????????????????}

????????????????}

????????????}

????????}

????}

????protected?void?setManage_Click(object?sender, EventArgs?e)

????{

????????Users?n = new?Users();

????????n.manageLanmuid = Convert.ToInt32(Request.QueryString["id"].ToString());

????????int?id = Convert.ToInt32(userList.SelectedValue);

????????Users?p = Users.getUserById(id.ToString());//根據欄目id找user

?

????????n.uid = p.uid;

????????n.userName = p.userName;

????????n.passWord = p.passWord;

????????if?(Users.giveUseraddlanmu(n) == true)

????????????Response.Write("<script>alert('設置成功')</script>");

????????else

????????????Response.Write("<script>alert('設置失敗')</script>");

????}

????protected?void?back_Click(object?sender, EventArgs?e)

????{

????????Response.Redirect("lanmuManage.aspx");

????}

}

新聞搜索(Search.aspx.cs):

public?partial?class?Search?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Request.QueryString["text"] != null)

????????{

????????????string?search = Request.QueryString["text"];

????????????SearchHotNews.DataSource = sqlhelper.excuteDataSet("select * from t_news where title like ?'%"?+ search + "%' or contents like '%"?+ search + "%' order by hitCount DESC");

????????????SearchHotNews.DataBind();

????????????SearchNews.DataSource = sqlhelper.excuteDataSet("select * from t_news where title like ?'%"?+ search + "%' or contents like '%"?+ search + "%' order by addTime DESC");

????????????SearchNews.DataBind();

????????}

????????else

????????{

????????}

????}

}

菜單欄目新聞(showlist.aspx.cs):

public?partial?class?showlist?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if?(Request.QueryString["id"] != null)

????????{

????????????//將欄目id作為參數,根據傳遞的欄目id值顯示

????????????string?id = Request.QueryString["id"].ToString();

????????????SqlConnection?con = sqlhelper.createCon();

????????????con.Open();

????????????string?sql = "select * from t_news where lanMuId=@lanMuId order by hitCount DESC";

????????????SqlCommand?cmd = con.CreateCommand();

????????????cmd.CommandText = sql;

????????????cmd.Parameters.Add(new?SqlParameter("@lanMuId", id));

????????????SqlDataAdapter?sda = new?SqlDataAdapter(cmd);

????????????DataSet?ds = new?DataSet();

????????????sda.Fill(ds);

????????????con.Close();

????????????gvHotNews.DataSource = ds;

????????????gvHotNews.DataBind();

????????????gvNews.DataSource = sqlhelper.excuteDataSet("select * from t_news order by addTime DESC");

????????????gvNews.DataBind();

????????}

????}

}

單篇新聞(shownews.aspx.cs:

public?partial?class?shownews?: System.Web.UI.Page

{

????protected?void?Page_Load(object?sender, EventArgs?e)

????{

????????if(Request.QueryString["id"]!=null)

????????{

????????????string?id=Request.QueryString["id"].ToString();

????????????News.addHitCount(id);

????????????News?n = News.getNewsById(id);

????????????lblTitle.Text = n.title;

????????????lblContent.Text = n.contents;

????????????lblAddTime.Text = "發布時間"+n.addTime.ToString();

????????????lblAuthor.Text ="發布者"+ n.uid.ToString();

????????????lblHitCount.Text ="點擊次數"+ n.hitCount;

????????}

????}

????protected?void?shownewssure_Click(object?sender, EventArgs?e)

????{

????????if?(shownewssure.Text.Trim() == "")

????????{

????????????Response.Write("<script>alert('輸入為空')</script>");

????????}

????????else

????????{

????????????Response.Redirect("Search.aspx?text="?+ shownewsSearch.Text);

????????}

????}

}

轉載于:https://www.cnblogs.com/mookking/p/9655240.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/396840.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/396840.shtml
英文地址,請注明出處:http://en.pswp.cn/news/396840.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

洛谷-求同構數的個數-NOIP2013提高組復賽

題目描述 Description 所謂同構數是指這樣的數&#xff0c;即它出現在它的平方數的右端。例如&#xff0c;5的平方是25 &#xff08;即5525&#xff09;&#xff0c;5是25右端的數&#xff0c;那么5就是同構數。又如&#xff0c;25的平方是625&#xff08;即2525625&#xff09…

plex linux 數據目錄,shareplex日常維護文檔

2017/07/25##SharePlex日常維護源(SRC)&#xff1a;192.168.1.101 db01目標(TGT):192.168.1.102 db02SRC:su - oraclesp_ctrlshowqstatusshow capture detailshow read detailshow log reverseshow config --查看當前使用參數文件list config --羅列出所有的參數文件(使用和未使…

ifconfig命令找不到_02. Linux命令之查看網絡連接

1. 查看網絡連接數和端口使用 netstat 命令查看網絡連接情況netstat -anp參數&#xff1a;-a 顯示所有選項-t (tcp)僅顯示tcp相關選項-u (udp)僅顯示udp相關選項-n 拒絕顯示別名&#xff0c;能顯示數字的全部轉化成數字。-p 顯示建立相關鏈接的程序名關鍵列解釋:Proto 表示協議…

grep與egrep的區別

grep與egrep的區別&#xff1b; 在linux系統環境下&#xff0c;我們通常使用grep命令來過濾出需要的行而egrep確很少使用&#xff0c;他們的區別其實很簡單&#xff0c;grep默認不支持正則表達式&#xff0c;egrep默認支持正則表達式&#xff0c;egrep 等于 grep -E 命令。轉載…

python學習之模塊(pip),列表生成式,模塊操作mysql,excel

python基礎 生成式 列表生成式  格式 [表達式 for 表達式 in 迭代對象 (可加判斷)] 原&#xff1a; 1 res1 [] 2 for i in range(1,5): 3   res1.append(i) 4 print(res1) 改&#xff1a; 1 res2 [i for i in range(1,5)] 2 print(res2) 字典生成式  格式 {key:value f…

linux驅動read函數 copytouser,Linux驅動編程 step-by-step (五)主要的文件操作方法實現...

主要的文件操作方法實現文件操作函數有很多的操作接口&#xff0c;驅動編程需要實現這些接口&#xff0c;在用戶編程時候系統調用時候會調用到這些操作structfile_operations {...loff_t (*llseek) (structfile *, loff_t,int);ssize_t (*read) (structfile *,char__user *,siz…

web開發中的 emmet 效率提升工具

web開發中的 emmet 效率提升工具 可以用來快速生成html 代碼。 并且給各種IDE、編輯器提供了插件支持&#xff0c;sublime &#xff0c;webstorm等。 如在webstorm中安裝好emmet之后&#xff0c;輸入以下文本&#xff0c; #page>div.content[ng-model"user"]ul>…

python二維數組操作_Python二維數組應用與操作

課課家將會在這里為大家詳細的介紹一下Python二維數組的相關應用方法以及定義方式&#xff0c;相信朋友們可以從中學習到更多的知識。 Python數組的應用中在實際編程中是一個非常重要的應用技術&#xff0c;作為Python編程人員來說&#xff0c;必須要熟練的掌握這方面的所有應用…

基于光線追蹤的渲染中景深(Depth of field)效果的實現

圖形學離線渲染中常用的透視攝像機模型時根據小孔成像的原理建立的&#xff0c;其實現通常是從向成像平面上發射ray&#xff0c;并把trace這條ray的結果作為成像平面上對應交點的采樣結果。即&#xff1a; 圖片來自《Fundamentals of Computer Graphics》 現實中的鏡頭拍攝的圖…

ubuntu 安裝 pycharm

添加源&#xff1a;$ sudo add-apt-repository ppa:mystic-mirage/pycharm安裝收費的專業版&#xff1a;$ sudo apt update$ sudo apt install pycharm安裝免費的社區版&#xff1a;$ sudo apt update$ sudo apt install pycharm-community卸載&#xff1a;$ sudo apt remove p…

帶你制作百詞斬單詞表讀寫插件

上篇博文簡單的介紹了一下Chrome插件&#xff0c;今天就與大家分享一下我做的這款有實際意義的插件吧。 做這款插件主要是用百詞斬站點進行單詞學習時&#xff0c;遇到的一點點鬧心事兒。在單詞表中不能聽發音。也不能練習拼寫。所以才忍無可忍的做了這么一款插件。自我感覺還是…

Linux7改運行級別,Centos7.0修改系統運行級別

首先翻譯下ininttab里面的內容&#xff1a;#inittab不再使用時利用系統。#添加配置這會對你的系統沒有影響。#Ctrl-Alt-Delete由/usr/lib系統/系統/ctrl-alt-del.target處理#系統使用的目標而不是運行級別。默認情況下&#xff0c;有兩個主要目標&#xff1a;#multi-user.targe…

python測試字符串類型的函數_python-02 數據類型 字符串str

字符串str 一、字符串定義 概念&#xff1a;字符串是有序的 不可修改的&#xff0c;元素以引號包圍的序列 引號類型&#xff1a;單引號 “”雙引號 “ ””三引號 三單引號 print(python) print("python") print(python) print("""python""…

POJ2115 C Looooops(線性同余方程)

無符號k位數溢出就相當于mod 2k&#xff0c;然后設循環x次A等于B&#xff0c;就可以列出方程&#xff1a; $$ CxA \equiv B \pmod {2^k} $$ $$ Cx \equiv B-A \pmod {2^k} $$ 最后就用擴展歐幾里得算法求出這個線性同余方程的最小非負整數解。 1 #include<cstdio>2 #incl…

工作測試博客

工作測試博客轉載于:https://blog.51cto.com/12559670/1895000

iphone各機型參數對比_帶你了解新款iPhone 12系列四款機型

2020年10月14日凌晨1&#xff1a;00&#xff0c;蘋果召開新品發布會&#xff0c;發布了新款iPhone 12系列手機&#xff0c;“果粉”們期待已久的iPhone 12終于來了。iPhone 12系列手機共有四款機型&#xff0c;分別是iPhone 12 mini、iPhone 12、iPhone 12 Pro、iPhone 12 Pro …

設置開機自啟動服務

一、軟鏈接方法 利用ln -s 命令將/etc/rc.d/init.d/目錄下腳本&#xff08;注意執行權限&#xff09;軟連接到 rc3目錄下&#xff0c;/etc/rc.d/rc3.d 目錄也就是我們一般的系統運行級別。ln -s /etc/rc.d/init.d/** /etc/rc.d/rc3.d/S**這里的S代表的是開機自啟動服務&#x…

mysql benchmark基準測試

git項目地址&#xff1a; https://github.com/akopytov/sysbench 利用sysbench很容易對mysql做性能基準測試&#xff08;當然這個工具很強大&#xff0c;除了測試主流數據庫性能&#xff0c;還能測試其它方面&#xff0c;詳情自己看官網項目文檔&#xff09; mac上的用法&#…

高并發第一彈:準備階段 了解高并發

高并發第一彈:準備階段 了解高并發 首先需要知道什么并發, 什么是高并發. 并發: 關于并發的學習&#xff0c;可以從JDK提供的并發包為核心開始&#xff0c;許多其他的類和封裝都是對其進行擴展或者補充&#xff0c;我們來看一下Java并發包(java.util.concurrent包&#xff0c;簡…

matlab立體坐標定位_【半導光電】基于光電探測器的激光章動定位算法(二)

今日光電有人說&#xff0c;20世紀是電的世紀&#xff0c;21世紀是光的世紀&#xff1b;知光解電&#xff0c;再小的個體都可以被賦能。歡迎來到今日光電&#xff01;----與智者為伍 為創新賦能----1. 章動定位算法實驗前&#xff0c;首先需要對光路進行調節&#xff0c;保證經…