1、计算机网络应用实习报告 班级: 网络工程11002 姓名: 吴超 学号: 201006421 实习日期: 2012.12.10---2012.12。19 1、课程实习的目的和要求: 实验目的: 计算机网络课程设计是《计算机网络》课程后的一个重要的教学环节,是对学生进行的一次较为全面的网络应用程序设计训练。其基本目的是: (1)培养学生理论联系实际的设计思想,训练综合运用所学的基础理论知识,结合生产实际分析和解决网络应用中问题的能力,从而使基础理论知识得到
2、巩固和加深. (2)学习掌握网络应用系统的一般设计过程和方法。 (3)熟悉并掌握运用网络应用中的B/S模式。 实验要求: (1)合理设计系统框图和网站结构图。 (2)根据系统框图设计,编写网页及程序代码. (3)程序设计时,要求使用Java或者。Net语言进行开发,完成课设题目的全部内容。 (4)完成课程设计报告。 2、 课程实习环境: 笔记本一台(win7 旗舰版,内安装有IIS); Dreamweaver cs6。0软件; Photoshop cs6.0软件; flash cs6。0软件; Sqlserver 2010数据库; Visual Stu
3、dio 2010; 3、 系统框图: 4、 系统源码: Default.aspx(登入界面): <%@ Page Language="C#” AutoEventWireup="true" CodeBehind=”Default。aspx。cs" Inherits="新?闻?发ぁ?布?.Default” %〉
4、//www.w3。org/1999/xhtml">
body{ background-image :url(”Images/2。jpg")} div{ margin-top:320px; margin-left:680px;} 〈/style>5、〈table cellpadding=8 cellspacing=0 border=0 〉 〈tr〉
6、td width=150〉密ü码?(辍assword)?:〈asp:TextBox TextMode=”Password" ID="txtpwd" runat=”server" Width=200 Height=25px/〉
7、utton ID=”Button2" runat="server" Text=”注痢?册á” Height=25px OnClick=”Button2_Click" Width=50px/〉〈/td〉 〈/tr〉
8、sing System。Web.UI。WebControls; using System.Data; using System。Data.SqlClient; namespace 新?闻?发ぁ?布? { public partial class Default : System。Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sen
9、der, EventArgs e) { string str = @”Data Source=。;Initial Catalog=新?闻?发ぁ?布?;User ID=jerry;Password=litian;Integrated Security=True"; SqlConnection con = new SqlConnection(str); con。Open(); string select = ”select Name,Password from tb_User
10、where Name=’"+txtAdmin.Text。Trim() + ”’and PassWord=’” + txtpwd.Text.Trim()+ "’”; SqlCommand cnd = new SqlCommand(select, con); SqlDataAdapter dataAdapter = new SqlDataAdapter(); dataAdapter.SelectCommand = cnd; DataSet myDs = new DataSet();
11、 dataAdapter。Fill(myDs); DataTable mytable = myDs.Tables[0]; if (myDs != null && myDs。Tables。Count >= 0 && myDs.Tables[0]。Rows.Count 〉 0) { Session[”Name”] = mytable.Rows[0][0].ToString(); Session["Password”] = mytable.Ro
12、ws[0][1]。ToString(); if (Session[”Name”].ToString() == txtAdmin.Text。Trim() && Session[”Password"]。ToString() == txtpwd。Text.Trim()) Response。Redirect(”HomePage。aspx"); } else { Response。Redirect(”Register.
13、aspx”); } con。Close(); } protected void Button2_Click(object sender, EventArgs e) { Response。Redirect(”Register。aspx”); } } } Register。aspx(注册界面): 〈%@ Page Language=”C#" AutoEventWireup="true” CodeBehind=”Register.asp
14、x.cs” Inherits=”新?闻?发ぁ?布?。Register" %> 〈!DOCTYPE html PUBLIC "—//W3C//DTD XHTML 1。0 Transitional//EN” ”http://www。w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”〉 〈title〉新?闻?发ぁ?布?〈/title〉 〈style type =”text/css"> b
15、ody{ background—image :url("images/register.jpg")} div{ margin—left :150px;margin—top :150px; font—size:large} 〈form id=”form1” runat="server”> 〈div>
| 登?入?失骸?败悒?请?先è注痢?册á:阰 | 〈td colspan=2〉用?户§注痢?册á:阰 〈tr width=400px height=17px 〉 〈td width=200px 〉用?户§号?(辍D)?:阰〈/td〉17、TextBox ID=”TextBox1” ForeColor=Black runat="server" Width=200px/〉〈/td〉 | 〈asp:RegularExpressionValidator ID=”RegularExpressionValidator2” runat=”server” ControlToValidate=”TextBox1”
ValidationExpression= \d{5} ErrorMessage="应畖为a5位?数簓字?">
18、essionValidator> |
〈/tr 〉
〈tr width=400px height=17px >
〈td width=200px>用?户§名?(辍serName)?:阰 〈td〉|||
| 〈/td> |
22、ionExpression=^[\w—]+(\。[\w-]+)*@[\w—]+(\。[\w—]+)+$ ErrorMessage=”必?须?使?用?通?用?邮?箱?"〉
〈tr width=400px height=17px 〉
| 电?话°号?码?(辍el)?:阰〈/td> | 24、{3}-)?\d{8}>〈/asp:RegularExpressionValidator>〈/td> |
25、 Register.aspx.cs: using System; using System.Collections。Generic; using System。Linq; using System.Web; using System。Web.UI; using System。Web。UI。WebControls; using System.Data; using System.Data.SqlClient; namespace 新?闻?发ぁ?布? { public partial class Register : System。Web。UI.Page {
26、 protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string str = @”Data Source=.;Initial Catalog=新?闻?发ぁ?布?;User ID=jerry;Password=litian;Integrated Security=True”;
27、SqlConnection con = new SqlConnection(str); con。Open(); string select = @"insert into tb_User(ID,Name,[Password],Email,Tel) values(’"+TextBox1。Text。Trim()+”',’”+TextBox2.Text。Trim()+"’,'"+TextBox3。Text.Trim()+”’,’"+TextBox5.Text。Trim()+"','”+TextBox6。Text。Trim()+"')";
28、 SqlCommand cnd = new SqlCommand(select, con); cnd。ExecuteNonQuery(); Response。Redirect("Default.aspx”); con.Close(); } } } MasterPage。master(母版): 〈%@ Master Language=”C#” AutoEventWireup=”true” CodeFile="mainMaster.master。cs" Inherits="
29、mainMaster” %〉 <%@ Register Src=”~/UserControl/head。ascx” TagName=”head" TagPrefix="uc1" %> <%@ Register Src=”~/UserControl/foot.ascx" TagName="foot” TagPrefix=”uc2" %〉 〈!DOCTYPE html PUBLIC ”—//W3C//DTD XHTML 1。0 Transitional//EN" ”http://www。w3.org/TR/xhtml1/DTD/xhtml1-transitional。dtd"〉
30、 xmlns=”http://www。w3.org/1999/xhtml"> 〈head runat="server">
32、eup="true” CodeBehind="head。ascx.cs” Inherits="新?闻?发ぁ?布?.UserControl.head” %> 〈style type=”text/css"> 。td1 { height: 35px; width: 19%; font-size: 12px; } 。td2 { width: 9%; height: 35px; font—size :15px; }
33、〉 〈table style ="width :100%"〉
34、/Images/logo。gif" /〉 〈/tr〉 〈tr style=”background—image: url(Images/b4_bg。gif)”〉 〈td class=”td1 "〉 〈asp:Label ID=”dateLabel” runat=”server" Style=”color: #FFFFFF">〈/asp:Label〉 〈td class=
35、td2 "> 〈asp:HyperLink ID=”HyperLink1” runat=”server” NavigateUrl="~/HomePage.aspx" Font-Underline="false” ForeColor="black" Style=”font—weight: 800; color: #FFFFFF;”〉首骸?页?
36、nk2" runat="server” NavigateUrl=”http://news。ifeng。com/”
Font—Underline=”false” ForeColor="black" Style=”font—weight: 700; color: #FFFFFF;”>时骸?事?
37、finance.ifeng。com/"
Font—Underline=”false" ForeColor=”black" Style="font-weight: 700; color: #FFFFFF;”>经-济?〈/asp:HyperLink〉
〈/td〉
〈td class="td2 "〉
〈asp:HyperLink ID="HyperLink4" runat="server” NavigateUrl="
Font-Underline=”false” Fore 38、Color="black" Style=”font-weight: 700; color: #FFFFFF;"〉军ü事?〈/asp:HyperLink〉
39、p:HyperLink〉
〈/td>
〈td class=”td2 ”>
〈asp:HyperLink ID=”HyperLink6" runat="server" NavigateUrl=”http://home。ifeng。com/”
Font—Underline="false" ForeColor="black" Style="font-weight: 700; color: #FFFFFF;"〉生Θ?活?
〈td 40、 class="td2 "〉
〈asp:HyperLink ID=”HyperLink7" runat="server” NavigateUrl=”http://bbs。ifeng。com/"
Font—Underline="false" ForeColor=”black” Style=”font—weight: 700; color: #FFFFFF;”〉社?会á〈/asp:HyperLink>
〈/td>
41、 ID=”HyperLink8" runat="server” NavigateUrl="http://sports。ifeng。com/”
Font—Underline="false" ForeColor="black” Style=”font-weight: 700; color: #FFFFFF;”>体?育畒
〈/td>
〈td class="td2 ”>
42、eUrl="
Font—Underline="false" ForeColor=”black" Style=”font—weight: 700; color: #FFFFFF;”>娱?乐?〈/asp:HyperLink>
43、关?键ü字?:阰
44、
45、〈/asp:ListItem>
〈asp:ListItem Value=7〉娱?乐?〈/asp:ListItem〉
〈/asp:DropDownList>
48、 Response。Redirect("经—济?。aspx");
if (DropDownList1。SelectedIndex == 2)
Response。Redirect(”军ü事?.aspx");
if (DropDownList1.SelectedIndex == 3)
Response.Redirect("科?技?.aspx”);
if (DropDownList1.SelectedIndex == 4)
49、 Response.Redirect("生Θ?活?。aspx”);
if (DropDownList1.SelectedIndex == 5)
Response.Redirect("社?会á。aspx”);
if (DropDownList1。SelectedIndex == 6)
Response.Redirect(”体?育畒.aspx");
if (DropDownList1.SelectedIndex == 7)
Response。Redirect("娱?乐?。aspx");
}
}
}
Homapage.aspx(主页):
〈%@ Page Language="C#” AutoEventWireup=”true" CodeBehind=”HomePage.aspx。cs" Inherits="新?闻?发ぁ?布?。HomePage"
MasterPageFile="~/mainMaster.maste
〈asp:HyperLink ID=”HyperLink5" runat="server" NavigateUrl="
Font—Underline="false” ForeColor=”black" Style="font-weight: 700; color: #FFFFFF;”>科?技?〈/as
〈asp:HyperLink
〈/tr>
〈p〉
〈span style=”text-align: left;”>输?入?