AS-PNET期末考試試題(有答案版)_第1頁
AS-PNET期末考試試題(有答案版)_第2頁
AS-PNET期末考試試題(有答案版)_第3頁
AS-PNET期末考試試題(有答案版)_第4頁
AS-PNET期末考試試題(有答案版)_第5頁
已閱讀5頁,還剩5頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

試卷序號:試卷序號:班級:學號:姓名:━━━━━━━━━裝━━━━━━━訂━━━━━━━線━━━━━━━━━防災科技學院2011~2012學年第1學期期末考試WEB應用技術(shù)試卷(A)使用班級0950411/0950412/0950421/0950422/0950423答題時間120分鐘題號一二三四五六總分得分閱卷教師得分一、程序設(shè)計題(本大題共6小題,共100分。)注意事項:請將此word文檔重新命名為:學號+姓名(如0533101張三),并在此文檔的首頁最上面填寫自己的姓名、學號和班級。程序完成后,僅提交此word文檔,需要將相關(guān)程序代碼(HTML代碼和后置cs程序代碼)拷貝至此word文檔中。3、在考試過程中,大家可以翻書或參閱資料,但是不允許使用任何移動存儲設(shè)備,也不允許和其他同學商談,凡有以上行為者,按考試作弊處理。4、嚴格完成題目要求的功能,擅自改動的,多做的,不計分!需求說明:實現(xiàn)一個簡單的新聞發(fā)布系統(tǒng),系統(tǒng)功能包括:1、系統(tǒng)首頁新聞瀏覽功能實現(xiàn);2、專題新聞的瀏覽和刪除;3、根據(jù)新聞標題進行查詢。 請打開名為web1的網(wǎng)站,其中App_Data文件夾下存放數(shù)據(jù)庫db_news_Data.MDF,大家可以直接使用或附加至SQLServer數(shù)據(jù)庫中使用,image文件夾下存放題目所需的圖片,然后按照要求完成如下所有功能:在web.config文件中,添加數(shù)據(jù)庫連接字符串,此連接串命名為“ConnectionString”,請將代碼復制到下面:(5分)<connectionStrings>StringCONN_STR=@”DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|web1.mdf;IntegratedSecurity=ture;</connectionStrings>設(shè)計頁眉、頁腳的用戶控件,然后添加到母版中。(30分)(1)為網(wǎng)站添加一名為header.ascx的頁眉用戶控件。(20分)a)頁面布局(10分)要求:效果如下圖(圖1)所示,使用一個4行1列的table進行布局,table的寬度為778px,在第1行內(nèi)添加一個1行2列的table,其中左側(cè)的單元格內(nèi)居左放置圖片“l(fā)ogo.png”,右側(cè)單元格內(nèi)居右放置Label標簽(ID為labDate),用于顯示系統(tǒng)的當前日期,格式為:今天是:×年×月×日;第2行單元格內(nèi)放置<img>標簽,并關(guān)聯(lián)圖片“index.png”;第3行添加控件1個名為“輸入關(guān)鍵字”的標簽控件,1個文本框控件(ID為txtKey),1個DropDownList控件(ID為ddlStyle,并手動添加相應的新聞類型:例如:“時政要聞”和“科學教育”等)和1個按鈕控件(ID為btnSearch),當用戶輸入標題內(nèi)容,點擊“站內(nèi)搜索”按鈕,將跳轉(zhuǎn)到Search.aspx網(wǎng)頁,并顯示模糊查找到新聞標題;第4行添加一個分割線。圖1請將上述界面的相關(guān)html代碼復制至此處:<%@ControlLanguage="C#"AutoEventWireup="true"CodeFile="header.ascx.cs"Inherits="header"%><styletype="text/css">.style1{width:100%;height:47px;}.style2{height:50px;}.style3{height:50px;width:509px;}</style><tablecellpadding="0"cellspacing="0"class="style1"width="778"><tr><td><tablecellpadding="0"cellspacing="0"class="style1"><tr><tdclass="style3"style="background-image:url('images/logo.png');background-repeat:no-repeat"></td><tdclass="style2"><asp:LabelID="labDate"runat="server"></asp:Label></td></tr></table></td></tr><tr><td><imgalt=""src=""style="background-image:url('images/index.png');background-repeat:no-repeat;width:707px;height:128px;"/></td></tr><tr><td><asp:LabelID="Label1"runat="server">輸入關(guān)鍵字</asp:Label><asp:TextBoxID="txtKey"runat="server"></asp:TextBox><asp:DropDownListID="ddlStyle"runat="server"></asp:DropDownList><asp:ButtonID="btnSearch"runat="server"Text="站內(nèi)搜索"onclick="btnSearch_Click"/></td></tr><tr><td><hr/></td></tr></table>b)顯示系統(tǒng)當前時間(5分)當頁面第一次加載時,在labDate標簽位置顯示系統(tǒng)的當前日期,格式為:今天是×年×月×日,請補充下列代碼:protectedvoidPage_Load(objectsender,EventArgse) { if(!IsPostBack){labDate.Text="今天是"+DateTime.Now.ToString("yyyy年MM月dd");} } c)專項搜索頁面(5分)當用戶輸入標題內(nèi)容,點擊站內(nèi)搜索按鈕,將跳轉(zhuǎn)到Search.aspx網(wǎng)頁,并將關(guān)鍵字以參數(shù)keyword的值傳遞至Search.aspx頁面,請補充下列代碼:protectedvoidbtnSearch_Click(objectsender,EventArgse) { stringurl="Search.aspx?t="+ddlStyle.SelectedValue+"&keyword="+txtKey.Text;Response.Redirect(url);}(2)創(chuàng)建名為footer.ascx的頁腳用戶控件。(5分)要求:如下圖(圖2)所示,使用一個2行1列的table進行布局,table的寬度為778px,第1行添加<img>標簽,并關(guān)聯(lián)圖片“底.jpg”,第2行添加相應文本。圖2請將上述界面的相關(guān)html代碼復制至此處:<%@ControlLanguage="C#"AutoEventWireup="true"CodeFile="footer.ascx.cs"Inherits="footer"%><styletype="text/css">.style1{width:100%;}</style><tablecellpadding="0"cellspacing="0"class="style1"width="778"><tr><td><imgalt=""src=""style="background-image:url('images/底.jpg');background-repeat:no-repeat;width:679px;height:19px;"/></td></tr><tr><tdalign="center">版權(quán)所有:災害信息工程系</td></tr></table>(3)建立名為MyMasterPage.master的母版頁。(5分)要求:模板頁效果圖如下圖(圖3)所示,在母版頁中添加一個3行1列的table。第1行,放置header用戶控件第2行,放置一個ContentPlaceHolder控件第3行,放置一個footer用戶控件。圖3請將上述界面的相關(guān)html代碼復制至此處:<%@MasterLanguage="C#"AutoEventWireup="true"CodeFile="MyMasterPage.master.cs"Inherits="MyMasterPage"%><%@Registersrc="header.ascx"tagname="header"tagprefix="uc1"%><%@Registersrc="footer.ascx"tagname="footer"tagprefix="uc2"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="/1999/xhtml"><headrunat="server"><title></title><asp:ContentPlaceHolderid="head"runat="server"></asp:ContentPlaceHolder><styletype="text/css">.style1{width:100%;}</style></head><body><formid="form1"runat="server"><div><tablecellpadding="0"cellspacing="0"class="style1"><tr><td><uc1:headerID="header1"runat="server"/></td></tr><tr><tdalign="left"valign="top"><asp:ContentPlaceHolderid="ContentPlaceHolder1"runat="server"></asp:ContentPlaceHolder></td></tr><tr><td><uc2:footerID="footer1"runat="server"/></td></tr></table></div></form></body></html>繼承MyMasterPage母版,新建內(nèi)容頁作為首頁,命名為index.aspx,界面如下圖(圖4)所示。(20分)圖4(1)頁面布局(10分)要求:依照圖4在ContentPlaceHolder1控件中添加table進行布局(效果和上圖基本一樣就可以),添加2個DataList,2個Image,2個ImageButton和相應的圖片。時政要聞中的DataList命名為dlSZ,科學教育中的DataList命名為dlKJ,在DataList控件的html代碼中添加LinkButton控件或超級鏈接控件或Label控件等,顯示為超級鏈接的效果。顯示最近的5條新聞標題;點擊科學教育部分“MORE”按鈕跳轉(zhuǎn)到newsList.aspx網(wǎng)頁,并將“科學教育”字符串傳遞過去。請將上述界面的相關(guān)html代碼復制至此處:<%@PageTitle=""Language="C#"MasterPageFile="~/MyMasterPage.master"AutoEventWireup="true"CodeFile="index.aspx.cs"Inherits="index"%><asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server"><styletype="text/css">.style4{height:50px;width:492px;}.style5{height:50px;width:421px;}</style></asp:Content><asp:ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><tablecellpadding="0"cellspacing="0"class="style1"><tr><tdclass="style2"><imgalt=""src=""style="background-image:url('images/時政要聞.jpg');background-repeat:no-repeat;width:87px;height:31px;"/></td><tdclass="style5"><asp:ImageButtonID="ImageButton1"runat="server"ImageAlign="Right"ImageUrl="~/images/更多.jpg"/></td><tdclass="style4"><imgalt=""src=""style="background-image:url('images/科學教育.jpg');background-repeat:no-repeat;height:28px;width:89px;"/></td><td><asp:ImageButtonID="ImageButton2"runat="server"ImageAlign="Right"ImageUrl="~/images/更多.jpg"onclick="ImageButton2_Click"/></td></tr><tr><tdclass="style2"><imgalt=""src=""style="background-image:url('images/時政要聞圖片.jpg');background-repeat:no-repeat;height:101px;width:89px;"/></td><tdclass="style5"><asp:DataListID="dlSZ"runat="server"RepeatColumns="1"RepeatDirection="Horizontal"><ItemTemplate><table><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr></table></ItemTemplate></asp:DataList></td><tdclass="style4"><imgalt=""src=""style="background-image:url('images/圖片科學教育.jpg');background-repeat:no-repeat;height:95px;width:90px;"/></td><td><asp:DataListID="dlKJ"runat="server"RepeatColumns="1"RepeatDirection="Horizontal"><ItemTemplate><table><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr><tr><ahref="shownews.aspx?Style=<%#Eval("Style")%>"></a></tr></table></ItemTemplate></asp:DataList></td></tr></table></asp:Content>(2)當頁面第一次加載時,在dlSZ中顯示時政要聞相關(guān)5條新聞,請補充下列代碼:(5分) protectedvoidPage_Load(objectsender,EventArgse){DataSetds=;dlSZ.DataSource=ds;dlSZ.DataBind();}3)當頁面第一次加載時,在dlKJ中顯示科學教育相關(guān)5條新聞,請補充下列代碼:(5分) protectedvoidPage_Load(objectsender,EventArgse){DataSetds=;dlKJ.DataSource=ds;dlKJ.DataBind();}建立站點地圖文件,命名為Web.sitemap,要求index.aspx為頂級節(jié)點,標題為“首頁”,Search.aspx和newsList.aspx為二級節(jié)點,標題分別為“搜索結(jié)果”和“新聞列表”。(10分)請將相關(guān)Web.sitemap代碼復制至此處:<?xmlversion="1.0"encoding="utf-8"?><siteMapxmlns="/AspNet/SiteMap-File-1.0"><siteMapNodeurl="index.aspx"title="首頁"description=""><siteMapNodeurl="Search.aspx"title="搜索結(jié)果"description=""/><siteMapNodeurl="NewList.aspx"title="新聞列表"description=""/></siteMapNode></siteMap>繼承MyMasterPage母版,新建內(nèi)容頁,命名為newsList.aspx,界面如下圖(圖5)所示。(25分)(1)頁面布局(5分)要求:添加導航控件SiteMapPath;GridView控件,命名為GVnews,啟用GridView1控件的分頁功能,每頁顯示5條記錄,頁碼格式為“第一頁、上一頁、下一頁、最后一頁”?!熬幪枴绷袑獢?shù)據(jù)表tb_News中ID字段;“標題”列對應數(shù)據(jù)表tb_News中Title字段;“內(nèi)容”列對應數(shù)據(jù)表tb_News中Content字段;“新聞類型”列對應數(shù)據(jù)表tb_News中Style字段;“新聞創(chuàng)建時間”列對應數(shù)據(jù)表tb_News中IssueDate字段,需要對其內(nèi)容進行格式化,僅需要顯示年月日信息(格式y(tǒng)yyy-mm-dd),不需要時間信息;“刪除”列為刪除列,用于刪除本行信息。圖5請將上述GVnews控件的html代碼復制于此處:<%@PageTitle=""Language="C#"MasterPageFile="~/MyMasterPage.master"AutoEventWireup="true"CodeFile="NewList.aspx.cs"Inherits="NewList"%><asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server"></asp:Content><asp:ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><tr><asp:SiteMapPathID="SiteMapPath1"runat="server"></asp:SiteMapPath></tr><tr><asp:GridViewID="GVnews"runat="server"AllowPaging="True"AutoGenerateColumns="False"onselectedindexchanged="GVnews_SelectedIndexChanged"PageSize="5"><PagerSettingsFirstPageText="第一頁"LastPageText="最后一頁"Mode="NextPreviousFirstLast"NextPageText=""PreviousPageText=""/><Columns><asp:HyperLinkFieldDataNavigateUrlFields="ID"DataTextField="ID"HeaderText="編號"Target="_self"/><asp:BoundFieldDataField="Title"HeaderText="標題"/><asp:BoundFieldDataField="Content"HeaderText="內(nèi)容"/><asp:BoundFieldDataField="Style"HeaderText="新聞類型"/><asp:BoundFieldDataField="IssueDate"DataFormatString="{0:yyyy-MM-dd}"HeaderText="新聞創(chuàng)建時間"/><asp:CommandFieldHeaderText="刪除"ShowDeleteButton="True"/></Columns></asp:GridView></tr></asp:Content>(2)在newsList.aspx.cs文件中,編寫InitData()方法,加載所有數(shù)據(jù)至GVnews控件中,并在Page_Load()事件中調(diào)用該方法。(10分)privatevoidInitData(){DataSetds=SearchUserByTitle;GVnews.DataSource=ds;GVnews.DataBind();}protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){InitData();}}(3)編程實現(xiàn)GVnews控件的刪除功能。(5分)protectedvoidGVnews_RowDeleted(objectsender,GridViewDeletedEventArgse){intindex=e.RowIndex;stringid=GVnews.DataKeys[index].Value.ToString();GVnewstbn=newGVnews();tbn.I

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論