web网站设计.docx
- 文档编号:9091254
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:12
- 大小:862.64KB
web网站设计.docx
《web网站设计.docx》由会员分享,可在线阅读,更多相关《web网站设计.docx(12页珍藏版)》请在冰豆网上搜索。
web网站设计
四川理工学院
实验报告
题目:
信息供求网
系别:
计算机学院
专业:
学号:
学生:
1.连接数据库
2.母版页
3.主页Default.aspx
利用表格布局,分类标题采用图片
(1)信息快速检索
从解决资源管理器中拖动一个InfoSearch.ascx到信息检索单元格
(2)招聘信息、求职信息、公寓信息等
从解决资源管理器中拖动一个RecommendInfo.ascx到信息检索单元格,并绑定数据。
(3)双击Default.aspx窗体空白处,并编写如下事件代码:
publicpartialclass_Default:
System.Web.UI.Page
{
Operationoperation=newOperation();//声明网站业唉务类对象
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!
IsPostBack)//!
IsPostBack避括免重复刷新加载页面
{
//获取前6条分类供求信息
DataList1.DataSource=operation.SelectLeaguerInfo(true,"招聘信息",6);
DataList1.DataBind();
DataList2.DataSource=operation.SelectLeaguerInfo(true,"培训信息",6);
DataList2.DataBind();
DataList3.DataSource=operation.SelectLeaguerInfo(true,"公寓信息",6);
DataList3.DataBind();
DataList4.DataSource=operation.SelectLeaguerInfo(true,"家教信息",6);
DataList4.DataBind();
DataList5.DataSource=operation.SelectLeaguerInfo(true,"物品求购",6);
DataList5.DataBind();
DataList6.DataSource=operation.SelectLeaguerInfo(true,"物品出售",6);
DataList6.DataBind();
DataList7.DataSource=operation.SelectLeaguerInfo(true,"求兑出兑",6);
DataList7.DataBind();
DataList8.DataSource=operation.SelectLeaguerInfo(true,"车辆信息",6);
DataList8.DataBind();
}
}
}
(4)创建模板页中的HyperLink控件对应的窗体并都应用于母版页
如招聘信息(webzp.aspx)、公寓信息(webgy.aspx)、物品求购(webwpqg.aspx)、求兑出兑(webqdcd.aspx)、寻求合作(webxqhz.aspx)、培训信息(webpx.aspx)、求职信息(webqz.aspx)、家教信息(webjj.aspx)、物品出售(webwqcs.aspx)、车辆信息(webcl.aspx)、企业广告(webqygg.aspx)。
例如:
webzp.aspx窗体的设计
1)右击新建的网站,选择“添加新项”,选择“web窗体”,名为“webzp.aspx”,选中“选择母版页”复选框,单击“确定”按钮。
2)切换到“设计”视图
在ContentPlaceHolder控件中插入表格,添加所需控件,如:
标准组中的image控件和Html组中的image控件、RecommendInfo控件、InfoSearch控件、LinkButton控件、Label控件及DataList控件。
对DataList控件进行编辑
选中DataList控件,单击右上角向右的箭头,选择“编辑模板”在ItemTemplate中输入以下两行:
[]
分别对LinkButton控件、DataList控件及窗体空白处编写如下事件代码:
publicpartialclasswebzp:
System.Web.UI.Page
{
Operationoperation=newOperation(); //声明业务类对象
staticstringinfoType="";//声明供求信息类型对象
staticstringinfoKey="";//声明查询信息关键字
staticPagedDataSourcepds=newPagedDataSource();//声明
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!
IsPostBack)
{
infoType="招聘信息";//infoKey的意思用语用户快速检索,如果值为空,显示所有招聘供求信息,否则显示查询内容
infoKey=Convert.ToString(Session["key"]);
this.DataListBind();//显示未过期收费信息
DataList1.DataSource=operation.SelectLeaguerInfo(true,infoType);
DataList1.DataBind();
Session["key"]=null;
}
}
///
///将数据绑定到DataList控件
///
publicvoidDataListBind()
{
//将分页结果设置结果赋值给新的页数据源对象
pds=operation.PageDataListBind(infoType,infoKey,Convert.ToInt32(Label1.Text),10);
LinkButton1.Enabled=true; //控件翻页控件都设置为可用LinkButton2.Enabled=true;
LinkButton3.Enabled=true;
LinkButton4.Enabled=true;
if(Label1.Text=="1")//如果当前显示第一页,“第一页”和“上一页”按钮不可用。
{
LinkButton1.Enabled=false;
LinkButton2.Enabled=false;
}
if(Label1.Text==pds.PageCount.ToString()) //如果显示最后一页,“末一页”和“下一页”按钮不可用。
{
LinkButton3.Enabled=false;
LinkButton4.Enabled=false;
}
Label2.Text=pds.PageCount.ToString(); //实现总页数
DataList2.DataSource=pds; //绑定数据源
DataList2.DataKeyField="id";
DataList2.DataBind();
}
protectedvoidlnkBtnFirst_Click(objectsender,EventArgse)
{
Label1.Text="1";//第一页
DataListBind();
}
protectedvoidlnkBtnPrevious_Click(objectsender,EventArgse)
{
Label1.Text=(Convert.ToInt32(Label1.Text)-1).ToString();//上一页
DataListBind();
}
protectedvoidlnkBtnNext_Click(objectsender,EventArgse)
{
Label1.Text=(Convert.ToInt32(Label1.Text)+1).ToString();//下一页
DataListBind();
}
protectedvoidlnkBtnLast_Click(objectsender,EventArgse)//最后一页
{
Label1.Text=Label2.Text;
DataListBind();
}
}
4.登录页面
也是利用表格布局,背景是一张图片,然后添加控件TextBox,Image,ImageButton和RequiredFieldValidator验证控件。
双击该窗体空白处,编写事件代码如下:
publicpartialclassBackGround_DetailInfo:
System.Web.UI.Page
{
Operationoperation=newOperation();
protectedvoidPage_Load(objectsender,EventArgse)
{
//Response.Write(Request.QueryString["id"].ToString()+""+Request.QueryString["type"].ToString());
DataSetds=operation.SelectInfo(Request.QueryString["type"].ToString(),Convert.ToInt32(Request.QueryString["id"].ToString()));
txtType.Text=ds.Tables[0].Rows[0][1].ToString();
txtTitle.Text=ds.Tables[0].Rows[0][2].ToString();
txtInfo.Text=ds.Tables[0].Rows[0][3].ToString();
txtLinkMan.Text=ds.Tables[0].Rows[0][4].ToString();
txtTel.Text=ds.Tables[0].Rows[0][5].ToString();
}
}
5.后台界面GQXXW.aspx
1)右击新建的网站,选择“添加新项”,选择“web窗体”,名为“GQXXW.aspx”,单击“确定”按钮。
2)切换到“设计”视图
拖动所需控件,选择其中的TreeView控件中,单击右上角的箭头,选择“编辑节点”在“TreeView节点编辑器”中对父节点进行如下设置:
其他父节点进行类似设置即可。
对子节点进行如下设置:
其他子节点进行类似设置即可。
窗体GQXXW.aspx的事件代码如下:
publicpartialclassBackGround_Default:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!
IsPostBack)
{try
{
if(Session["UserName"].ToString().ToLower()!
="TSOFT".ToLower())
WebMessageBox.Show("请登录后方可进入网站后台!
","../Logon.aspx");
}
catch{}
}
}
publicvoidPageExit()
{
Session["UserName"]="";
Response.Write("../Default.aspx")}
}
6.LeaguerInfoDelete.aspx
1)右击新建的网站,选择“添加新项”,选择“web窗体”,名为“LeaguerInfoDelete.aspx”,单击“确定”按钮。
2)切换到“设计”视图
拖动三个RadioButton控件,一个GridView控件。
对三个RadioButton控件的GroupName属性都设为info。
对GridView控件进行如下图的设置:
再对GridView控件属性进行如下设置:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- web 网站 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)