资源描述
计算机网络应用实习报告
班级: 网络工程11002
姓名: 吴超
学号: 201006421
实习日期: 2012.12.10---2012.12。19
1、课程实习的目的和要求:
实验目的:
计算机网络课程设计是《计算机网络》课程后的一个重要的教学环节,是对学生进行的一次较为全面的网络应用程序设计训练。其基本目的是:
(1)培养学生理论联系实际的设计思想,训练综合运用所学的基础理论知识,结合生产实际分析和解决网络应用中问题的能力,从而使基础理论知识得到巩固和加深.
(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 Studio 2010;
3、 系统框图:
4、 系统源码:
Default.aspx(登入界面):
<%@ Page Language="C#” AutoEventWireup="true" CodeBehind=”Default。aspx。cs" Inherits="新?闻?发ぁ?布?.Default” %〉
<!DOCTYPE html PUBLIC ”—//W3C//DTD XHTML 1.0 Transitional//EN” "http://www.w3.org/TR/xhtml1/DTD/xhtml1—transitional。dtd”>
<html xmlns=”http://www.w3。org/1999/xhtml">
<head runat="server”〉
<title〉新?闻?发ぁ?布?</title〉
<style type="text/css”>
body{ background-image :url(”Images/2。jpg")}
div{ margin-top:320px; margin-left:680px;}
〈/style>
</head>
<body〉
〈form id=”form1" runat="server">
<div〉
〈table cellpadding=8 cellspacing=0 border=0 〉
〈tr〉
<td style = "font-size:large"〉欢?迎?你?的?到?来ぁ?:阰〈/td〉
</tr>
<tr>
〈td width=150>用?户§名?(UserName):〈/td〉〈td><asp:TextBox ID=”txtAdmin" runat="server" Width=200 Height=25px/〉</td>
〈/tr>
〈tr>
〈td width=150〉密ü码?(辍assword)?:</td〉〈td >〈asp:TextBox TextMode=”Password" ID="txtpwd" runat=”server" Width=200 Height=25px/〉</td〉
</tr>
<tr>
〈td 〉<asp:Button ID="Button1” runat="server" Text="确ā?认?" Height=25px OnClick="Button1_Click" Width=50px/>〈/td〉
<td 〉<asp:Button ID=”Button2" runat="server" Text=”注痢?册á” Height=25px OnClick=”Button2_Click" Width=50px/〉〈/td〉
〈/tr〉
</table〉
〈/div〉
〈/form〉
〈/body〉
〈/html〉
Default。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 Default : System。Web.UI.Page
{
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";
SqlConnection con = new SqlConnection(str);
con。Open();
string select = ”select Name,Password from tb_User 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();
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.Rows[0][1]。ToString();
if (Session[”Name”].ToString() == txtAdmin.Text。Trim() && Session[”Password"]。ToString() == txtpwd。Text.Trim())
Response。Redirect(”HomePage。aspx");
}
else
{
Response。Redirect(”Register.aspx”);
}
con。Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
Response。Redirect(”Register。aspx”);
}
}
}
Register。aspx(注册界面):
〈%@ Page Language=”C#" AutoEventWireup="true” CodeBehind=”Register.aspx.cs” Inherits=”新?闻?发ぁ?布?。Register" %>
〈!DOCTYPE html PUBLIC "—//W3C//DTD XHTML 1。0 Transitional//EN” ”http://www。w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”〉
<html xmlns=”http://www。w3.org/1999/xhtml”〉
〈head runat=”server">
〈title〉新?闻?发ぁ?布?〈/title〉
〈style type =”text/css">
body{ background—image :url("images/register.jpg")}
div{ margin—left :150px;margin—top :150px; font—size:large}
</style〉
〈/head〉
<body>
〈form id=”form1” runat="server”>
〈div>
<table border=0 align=center cellpadding =10px cellspacing =8px style="Font-Size:large"〉
〈tr style=”font-size:larger”>
<td colspan=2 >登?入?失骸?败悒?请?先è注痢?册á:阰</td〉
</tr〉
<tr style="Font-Size:x—large” width=400px height =17px >
〈td colspan=2〉用?户§注痢?册á:阰</td>
</tr>
〈tr width=400px height=17px 〉
〈td width=200px 〉用?户§号?(辍D)?:阰〈/td〉 <td〉<asp:TextBox ID=”TextBox1” ForeColor=Black runat="server" Width=200px/〉〈/td〉
<td> 〈asp:RegularExpressionValidator ID=”RegularExpressionValidator2” runat=”server” ControlToValidate=”TextBox1”
ValidationExpression= \d{5} ErrorMessage="应畖为a5位?数簓字?">
</asp:RegularExpressionValidator></td>
〈/tr 〉
〈tr width=400px height=17px >
〈td width=200px>用?户§名?(辍serName)?:阰</td> 〈td〉<asp:TextBox ID="TextBox2" ForeColor=Black runat="server" Width=200px/〉</td>
〈/tr〉
<tr width=400px height=17px 〉
〈td width=200px〉密ü码?(辍assword)?:阰</td〉 〈td〉<asp:TextBox ID=”TextBox3" TextMode="Password” ForeColor=Black runat=”server" Width=200px/〉</td〉
</tr〉
<tr width=400px height=17px >
〈td width=200px〉确ā?认?密ü码?(辍assword)?:阰〈/td〉 <td〉〈asp:TextBox ID=”TextBox4” TextMode ="Password" ForeColor=Black runat="server" Width=200px/>〈/td>
<td width=200px〉〈asp:CompareValidator ID="CompareValidator1” runat="server” ControlToCompare="TextBox3" ControlToValidate=”TextBox4"
ErrorMessage=”密ü码?不?一?致?” Display="Dynamic”〉〈/asp:CompareValidator〉〈/td>
</tr>
〈tr width=400px height=17px 〉
〈td width=230px>邮?箱?(辍mail)?:阰</td> <td><asp:TextBox ID=”TextBox5” ForeColor=Black runat=”server" Width=200px/></td>
<td width=200px>
<asp:RegularExpressionValidator ID=”RegularExpressionValidator3" runat="server” ControlToValidate="TextBox5" ValidationExpression=^[\w—]+(\。[\w-]+)*@[\w—]+(\。[\w—]+)+$
ErrorMessage=”必?须?使?用?通?用?邮?箱?"〉</asp:RegularExpressionValidator>
<td/〉
</tr>
〈tr width=400px height=17px 〉
<td width=200px>电?话°号?码?(辍el)?:阰〈/td> <td〉<asp:TextBox ID="TextBox6” ForeColor=Black runat=”server” Width=200px/>〈/td>
<td width=200px>
〈asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox6"
ErrorMessage="(021)12345678或ò021-12345678" ValidationExpression=(\(\d{3}\))|(\d{3}-)?\d{8}>〈/asp:RegularExpressionValidator>〈/td>
</tr〉
<tr width=400px height=17px 〉
〈td width=200px>提?交?(Sumit):〈/td〉 〈td〉<asp:Button ID="Button1" runat=”server” Text=”提?交?" OnClick=”Button1_Click” />
〈/tr〉
</table〉
</div>
</form〉
</body〉
</html〉
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
{
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”;
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()+"')";
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="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"〉
<html xmlns=”http://www。w3.org/1999/xhtml">
〈head runat="server">
<title〉〈/title>
〈link rel=”Stylesheet” type=”text/css” href="css/Style.css” />
</head〉
<body class="tempbody">
<form id=”form1" runat="server"〉
〈div class =”tbody">
〈uc1:head ID=”head" runat="server" />
〈/div〉
<asp:ContentPlaceHolder ID=”ContentPlaceHolder1" runat="server”>
<div align="left”></div>
</asp:ContentPlaceHolder〉
〈div class =”footer"〉
<uc2:foot ID="foot” runat="server” />
〈/div>
</form〉
</body〉
〈/html>
Head。ascx:
<%@ Control Language=”C#” AutoEventWireup="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;
}
</style〉
〈table style ="width :100%"〉
<tr〉
<td colspan=”10">
<div class="wishTop"〉
<div class=”titleSystemName">
新?闻?发ぁ?布?系μ统?</div〉
<div class="bglogo"〉
〈asp:Image ID=”Image1” runat="server" ImageUrl="~/Images/logo。gif" /〉
</div>
</div>
</td>
〈/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>
〈td class=”td2 ">
〈asp:HyperLink ID=”HyperLink1” runat=”server” NavigateUrl="~/HomePage.aspx" Font-Underline="false”
ForeColor="black" Style=”font—weight: 800; color: #FFFFFF;”〉首骸?页?</asp:HyperLink〉
〈/td〉
<td class="td2 ”〉
〈asp:HyperLink ID="HyperLink2" runat="server” NavigateUrl=”http://news。ifeng。com/”
Font—Underline=”false” ForeColor="black" Style=”font—weight: 700; color: #FFFFFF;”>时骸?事?</asp:HyperLink>
</td〉
<td class=”td2 ">
<asp:HyperLink ID="HyperLink3” runat="server" NavigateUrl=”http://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” ForeColor="black" Style=”font-weight: 700; color: #FFFFFF;"〉军ü事?〈/asp:HyperLink〉
</td>
<td class=”td2 ”>
〈asp:HyperLink ID=”HyperLink5" runat="server" NavigateUrl="
Font—Underline="false” ForeColor=”black" Style="font-weight: 700; color: #FFFFFF;”>科?技?〈/asp: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;"〉生Θ?活?</asp:HyperLink〉
〈/td>
〈td 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>
<td class=”td2 ”>
〈asp:HyperLink ID=”HyperLink8" runat="server” NavigateUrl="http://sports。ifeng。com/”
Font—Underline="false" ForeColor="black” Style=”font-weight: 700; color: #FFFFFF;”>体?育畒</asp:HyperLink>
〈/td>
〈td class="td2 ”>
<asp:HyperLink ID="HyperLink9" runat="server" NavigateUrl="
Font—Underline="false" ForeColor=”black" Style=”font—weight: 700; color: #FFFFFF;”>娱?乐?〈/asp:HyperLink>
</td>
〈/tr>
<tr>
<td style="height: 25px; font—size: 12px" colspan="10">
〈p〉
〈span style=”text-align: left;”>输?入?关?键ü字?:阰
<asp:TextBox ID=”txtKey" runat="server" Width="173px”>〈/asp:TextBox〉
<asp:DropDownList ID="DropDownList1" runat="server">
〈asp:ListItem Value=0〉时骸?事?</asp:ListItem>
〈asp:ListItem Value=1>经-济?〈/asp:ListItem〉
<asp:ListItem Value=2>军ü事?〈/asp:ListItem〉
〈asp:ListItem Value=3>科?技?</asp:ListItem>
<asp:ListItem Value=4〉生Θ?活?〈/asp:ListItem〉
<asp:ListItem Value=5>社?会á</asp:ListItem>
〈asp:ListItem Value=6〉体?育畒〈/asp:ListItem>
〈asp:ListItem Value=7〉娱?乐?〈/asp:ListItem〉
〈/asp:DropDownList>
<asp:Button ID=”Button1” runat="server” Text="搜?索÷" OnClick="Button1_Click” /〉</span>〈/p〉
</td〉
</tr>
</table>
Head.ascx。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 新?闻?发ぁ?布?.UserControl
{
public partial class head : System.Web.UI。UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 0)
Response.Redirect(”时骸?事?。aspx");
if (DropDownList1。SelectedIndex == 1)
Response。Redirect("经—济?。aspx");
if (DropDownList1。SelectedIndex == 2)
Response。Redirect(”军ü事?.aspx");
if (DropDownList1.SelectedIndex == 3)
Response.Redirect("科?技?.aspx”);
if (DropDownList1.SelectedIndex == 4)
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
展开阅读全文