基于web程序設計練習題答案_第1頁
基于web程序設計練習題答案_第2頁
基于web程序設計練習題答案_第3頁
基于web程序設計練習題答案_第4頁
基于web程序設計練習題答案_第5頁
已閱讀5頁,還剩124頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、.基于Web程序設計練習題一參考答案一、HTML代碼分析1. 根據(jù)網(wǎng)頁截圖效果補充代碼。(5分)<html> <head> <title> 我的網(wǎng)頁 </title> </head> <body> </body></html>2. 根據(jù)網(wǎng)頁截圖效果補充代碼。(10分)<html> <head> </head> <body> <form> <input type="text" name="name"

2、; /><BR/> <input type="password" name="psw" /><BR/> <input type="hidden" name="hidden" /><br/> <br/> <input type="radio" name="sex" value="male" /> male <br/> <input type="

3、;radio" name="sex" value="female" /> Female <br/> <input type="radio" name="driver" value="car" /> car <br/> <br/> <input type="checkbox" name="apple" />I have a apple <br /> <input t

4、ype="checkbox" name="orange" /> I have a orange <br/> <input type="submit" value="Submit" /> <input type="reset" value="Reset" /> </form> </body></html>3. 根據(jù)網(wǎng)頁截圖效果補充代碼。(5分)<table border="1"

5、;> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr></table>二、數(shù)據(jù)庫基礎代碼分析 1. 解釋代碼:請解釋下述代碼的含義。(5分)INSERT INTO article ( title, writer, content )VALUES (實驗, 學生

6、, 插入數(shù)據(jù));答案要點:加入一條記錄。2. 解釋代碼:請解釋下述代碼的含義。(5分)SELECT *FROM articleWHERE 編號=1;答案要點:查詢符合條件的記錄。3. 解釋代碼:請解釋下述代碼的含義。(5分)UPDATE article SET content = 修改WHERE 編號=1;答案要點:修改符合條件的記錄。4. 解釋代碼:請解釋下述代碼的含義。(5分)DELETE *FROM articleWHERE 編號=1;答案要點:刪除符合條件的記錄。三、標準控件代碼分析 1. 解釋代碼:請解釋下述代碼的含義。(10分)ButtonEx.aspx :<% Page L

7、anguage="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http:/w

8、/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> <br /> <asp:Button ID="Button1" runat="server" Text="確定" /> &

9、lt;asp:Label ID="Label1" runat="server"></asp:Label></div> </form></body></html>-ButtonEx.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

10、 Response.Write("通過按鈕的Click事件觸發(fā)后顯示!") End Sub Protected Sub Button1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles Button1.Command Label1.Text = Label1.Text + "1" End SubEnd Class答案要點:ButtonEx控件應用。點擊按鈕后顯示“通過按鈕的Click事件觸發(fā)后顯示!”。2. 解釋代碼

11、:請解釋下述代碼的含義。(10分)DropDownList.aspx :<% Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transi

12、tional.dtd"><html xmlns="/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat

13、="server" AutoPostBack="True"> <asp:ListItem>Item1</asp:ListItem> <asp:ListItem>Item2</asp:ListItem> <asp:ListItem>Item3</asp:ListItem> </asp:DropDownList> <asp:Label ID="Label1" runat="server"></asp:Label&

14、gt;</div> </form></body></html>-DropDownList.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged Label1.Text = DropDownList1.Sel

15、ectedItem.Value.ToString() End SubEnd Class-答案要點:DropDownList控件應用。在結果頁(同一頁)顯示選中的元素。3. 解釋代碼:請解釋下述代碼的含義。(10分)RadioButtonListEx.aspx :<% Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC &qu

16、ot;-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" r

17、unat="server"> <div> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>Item1</asp:ListItem> <asp:ListItem>Item2</asp:ListItem> <asp:ListItem>Item3</asp:ListItem> </asp:RadioButtonList></d

18、iv> <asp:Button ID="Button1" runat="server" Text="OK" /><br /> <asp:Label ID="Label1" runat="server" BackColor="White" ForeColor="Black"></asp:Label> </form></body></html>-RadioButtonLi

19、stEx.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If RadioButtonList1.SelectedIndex =

20、0 Then Label1.Text = "1" End If If RadioButtonList1.SelectedIndex = 1 Then Label1.Text = "2" End If If RadioButtonList1.SelectedIndex = 2 Then Label1.Text = "3" End If End SubEnd Class答案要點:單選按鈕控件應用。在結果頁顯示選中的單選按鈕。4. 解釋代碼:請解釋下述代碼的含義。(10分)CalendarEx.aspx :<% Page Langua

21、ge="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http:/www.w3

22、.org/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor=&

23、quot;White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" Width="350px"> <SelectedDayStyle BackColor="#333399" ForeColor="White" /

24、> <TodayDayStyle BackColor="#CCCCCC" /> <OtherMonthDayStyle ForeColor="#999999" /> <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" /> <DayHeaderStyle Font-Bold="True&qu

25、ot; Font-Size="8pt" /> <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-Size="12pt" ForeColor="#333399" /> </asp:Calendar> <br /> <asp:Label ID="Label1" ru

26、nat="server"></asp:Label>&nbsp;</div> </form></body></html>-CalendarEx.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChange

27、d Label1.Text = Calendar1.SelectedDate.ToShortDateString() End SubEnd Class答案要點:CalendarEx控件。在結果頁(同一頁)顯示選中的日期。四、網(wǎng)絡基礎名詞解釋 1. 請解釋如圖所示模型的含義。(5分)答案要點:C/S模型。由client上運行的應用程序發(fā)起與server的SQL會話。server之上運行著數(shù)據(jù)庫。客戶端與服務端的所有通信,都以直接的SQL語句形勢存在。server返回client請求的數(shù)據(jù)集,由client進行處理后顯示出來。界面在client上以Windows應用程序的方式直接顯示。業(yè)務邏輯和界

28、面顯示都在client上,server端除數(shù)據(jù)庫以外不提供任何功能。這實現(xiàn)了數(shù)據(jù)和業(yè)務邏輯的分離。2. 請解釋如圖所示模型的含義。(5分)答案要點:當一臺主機信源向另一臺主機信宿發(fā)送信息時,如圖通信過程所示,由信源的應用層、TCP層、IP層、主機到網(wǎng)絡層進行層層的封裝,在每一層的數(shù)據(jù)包包頭內加入地址、糾錯等控制信息,然后發(fā)送到網(wǎng)絡中。在另一臺主機信宿的主機到網(wǎng)絡層接收到數(shù)據(jù),由IP層、TCP層、應用層進行層層解封裝,并得到控制信息。最后保留的信息即信源主機應用程序發(fā)送的信息。3. 請給出網(wǎng)絡工具ipconfig的作用。(5分)答案要點:ipconfig是Windows下判定TCP/IP配置的工

29、具。4. 請解釋如圖所示模型的含義。(5分)答案要點:B/S模型。以ASP程序為例,由browser發(fā)起服務請求,其請求通過HTTP協(xié)議提交給web server的一個ASP頁面。該頁面在執(zhí)行中,通過SQL會話向數(shù)據(jù)庫提交請求,并獲得數(shù)據(jù)集,以HTML的形式把處理后的結果提供給browser。browser顯示HTML結果。界面在browser上以瀏覽器解釋和渲染HTML頁面的方式顯示。業(yè)務邏輯運行在web server上,界面的解釋和顯示由browser完成,這實現(xiàn)了業(yè)務邏輯和表現(xiàn)的分離。五、站點開發(fā)控件代碼分析1. 解釋代碼:請解釋下述代碼的含義。(10分)CompareValidator

30、Ex.aspx :<% Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htm

31、l xmlns="/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="開始時間"

32、></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <asp:Label ID="Label2" runat="server" Text="結束時間"></asp:Label> <asp:TextBox ID="TextBox2" runat="server"><

33、;/asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="CompareValidator" Operator="GreaterThan" Type="Date">結束時間必需大于開始時間</asp:C

34、ompareValidator><br /> <asp:Button ID="Button1" runat="server" Text="確定" /></div> </form></body></html>-CompareValidatorEx.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, B

35、yVal e As System.EventArgs) Handles Button1.Click CompareValidator1.Validate() If (CompareValidator1.IsValid = True) Then Response.Write("通過檢驗") End If End SubEnd Class答案要點:CompareValidator應用。以用戶輸入的兩組數(shù)據(jù)的差異作為檢驗條件。2. 解釋代碼:請解釋下述代碼的含義。(10分)SiteMapPathEx.master :<% Master Language="VB&q

36、uot; %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="/1999/xhtml" ><head runat="server"&

37、gt; <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em" PathSeparator=" : "> &l

38、t;PathSeparatorStyle Font-Bold="True" ForeColor="#5D7B9D" /> <CurrentNodeStyle ForeColor="#333333" /> <NodeStyle Font-Bold="True" ForeColor="#7C6F57" /> <RootNodeStyle Font-Bold="True" ForeColor="#5D7B9D" /> &

39、lt;/asp:SiteMapPath> <br /> <br /> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form></body></html>-SiteMapPathEx.sitemap :<?xml version="1.0" encoding="utf

40、-8" ?><siteMap xmlns=" > <siteMapNode url="Default2.aspx" title="主頁" description=""> <siteMapNode url="" title="博客" description="" /> <siteMapNode url="" title="鏈接" description="&qu

41、ot; /> <siteMapNode url="Default3.aspx" title="個人信息" description="" /> <siteMapNode url="" title="相冊" description="" /> </siteMapNode></siteMap>-SiteMapPathEx_Default2.aspx :<% Page Language="VB" Mast

42、erPageFile="/MasterPage.master" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="/Default3.as

43、px">轉至個人信息頁面</asp:HyperLink></asp:Content>-SiteMapPathEx_Default3.aspx :<% Page Language="VB" MasterPageFile="/MasterPage.master" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1&quo

44、t; Runat="Server"></asp:Content>答案要點:SiteMapPathEx控件應用,給出站點地圖。3. 解釋代碼:請解釋下述代碼的含義。(10分)TreeViewEx.aspx :<% Page Language="VB" MasterPageFile="/MasterPage.master" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID

45、="ContentPlaceHolder1" Runat="Server"></asp:Content>-TreeViewEx.master :<% Master Language="VB" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script run

46、at="server"></script><html xmlns="/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> &nbsp;<table border="0&

47、quot; cellpadding="0" cellspacing="0" style="width: 100%; height: 100%"> <tr> <td style="width: 200px"> <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" /> <asp:TreeView ID="TreeView1" runat=&q

48、uot;server" DataSourceID="SiteMapDataSource1" ImageSet="Arrows"> <ParentNodeStyle Font-Bold="False" /> <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" /> <SelectedNodeStyle Font-Underline="True" ForeColor=&q

49、uot;#5555DD" HorizontalPadding="0px" VerticalPadding="0px" /> <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" /> </asp:Tr

50、eeView> </td> <td> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </td> </tr> </table> </div> </form></body></html>-TreeViewEx.sitemap :<?xml version="1.0"

51、; encoding="utf-8" ?><siteMap xmlns=" > <siteMapNode url="Default.aspx" title="主頁" description=""> <siteMapNode url="" title="博客" description="" /> <siteMapNode url="" title="鏈接" de

52、scription="" /> <siteMapNode url="Default2.aspx" title="個人信息" description="" /> <siteMapNode url="" title="相冊" description="" /> </siteMapNode></siteMap>答案要點:TreeViewEx控件應用。顯示樹狀站點地圖。4. 解釋代碼:請解釋下述代碼的含義。(1

53、0分)ValidationSummaryEx.aspx :<% Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.

54、dtd"><html xmlns="/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" T

55、ext="姓名"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="None" ErrorMessag

56、e="姓名不能為空"></asp:RequiredFieldValidator><br /> <asp:Label ID="Label2" runat="server" Text="郵箱"></asp:Label> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RegularExpressionValidator I

57、D="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox2" Display="None" ErrorMessage="郵箱格式錯誤" ValidationExpression="w+(-+.'w+)*w+(-.w+)*.w+(-.w+)*"></asp:RegularExpressionValidator> <asp:Button ID="Bu

58、tton1" runat="server" Text="確定" /><br /> <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="表單錯誤:" /> </div> </form></body></html>-ValidationSummaryEx.vb :Partial Class _Default Inher

59、its System.Web.UI.PageEnd Class答案要點:Validator控件應用,對姓名是否為空和郵箱格式等進行了檢查。5. 解釋代碼:請解釋下述代碼的含義。(10分)CustomValidatorEx.aspx :<% Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD X

60、HTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml" ><head runat="server"> <title>無標題頁</title></head><body> <form id="form1" runat="ser

61、ver"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToVa

62、lidate="TextBox1" ErrorMessage="CustomValidator">不是偶數(shù)</asp:CustomValidator></div> </form></body></html>-CustomValidatorEx.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub CustomValidator1_ServerValidate(ByVal source As Object,

63、ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate Dim i As Integer i = Integer.Parse(args.Value) If i Mod 2 = 0 Then args.IsValid = True Else args.IsValid = False End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As Syst

64、em.EventArgs) Handles Button1.Click CustomValidator1.Validate() If (CustomValidator1.IsValid = True) Then Response.Write("通過檢驗") End If End SubEnd Class答案要點:CustomValidator應用。檢查用戶輸入是否符合定制的要求。6. 解釋代碼:請解釋下述代碼的含義。(10分)LoginEx.aspx :<% Page Language="VB" AutoEventWireup="fals

65、e" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml" ><head runat=&qu

66、ot;server"> <title>無標題頁</title></head><body> <form id="form1" runat="server"> <div> &nbsp;</div> </form></body></html>-LoginEx.vb :Partial Class _Default Inherits System.Web.UI.Page Protected Sub Login1_Authe

67、nticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate End SubEnd Class答案要點:LoginEx應用。六、內建組建對象代碼分析 1. 解釋代碼:請解釋下述代碼的含義。(10分)Application.aspx :<% Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http:/www

溫馨提示

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

最新文檔

評論

0/150

提交評論