教务信息管理系统实验报告_第1页
教务信息管理系统实验报告_第2页
教务信息管理系统实验报告_第3页
教务信息管理系统实验报告_第4页
教务信息管理系统实验报告_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

.Net程序设计实验报告ASP.NET 班级:计10A-1姓名:黄溥学号:10101020114日期:2013年5月22日一、实验目的及要求1. 熟悉Cookie, Response, Request, Session, Server, Application等对象。2. 实现用户登录cookie的保存。3. 实现用户登录信息的Session保存。4. 实现用户上传文件(Server对象)。二、程序功能1. 各个网页间的切换,打开,关闭及退出。2. 用户的登陆判断。3. 新建数据源,连接并打开数据库。4. 三种数据操作的使用:GridView,DetailsView,DropDownList。三、程序结构1. Default:登陆窗口。2. Default2:数据的操作窗口。四、源程序1. Default源程序:using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient; public partial class Default : Page protected void Button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(); conn.ConnectionString = Data Source=RenatoPuPC;Initial Catalog=JiaoWu;Integrated Security=True; try conn.Open(); string no= TextBox1.Text; string password = TextBox2.Text; string str_sql = select count(*) from Students where Student_No=Student_No and Student_Password=Student_Password; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = str_sql; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter(Student_No, no);/给sql语句内Student_No参数赋值,传递学号no cmd.Parameters.Add(new SqlParameter(Student_Password, password);/给sql语句内Student_Name参数赋值,传递学号name int count = Convert.ToInt32(cmd.ExecuteScalar(); if (count 0) Response.Redirect(Default2.aspx); else Response.Write(用户名密码输入错误); finally conn.Close(); 2.Default2源程序:using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;public partial class Default2 : System.Web.UI.Page protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) DetailsView1.ChangeMode(DetailsViewMode.Edit); protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) GridView1.SelectedIndex = -1; GridView1.DataBind(); protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e) GridView1.SelectedIndex = -1; GridView1.DataBind(); protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e) GridView1.SelectedIndex = -1; GridView1.DataBind(); 五、数据库六、运行截图七、实验问题及解决1. 模板页总是无法显示或显示错误,通过询问同学和请教老师得出正确的模板使用步骤如下:1) 新建模板页。2) 在资源管理器中导入“images文件夹”“.html”“.css”文件。3) 选中.html设计选项卡中的表格,源选项卡中复制已经选中代码上面的非选中代码由下到上至div复制到master的源选项卡的div ,源选项卡中复制已经选中代码下面的非选中代码由上到下至div复制到master的源选项卡的div。4) 然后再在新建页面(选择母版页)上设计除模板以外的控件。u 本次实验直接把.html中的样式拷贝到了新建页面上,模板页没起作用。2. 关于数据绑定混乱问题:解决办法是用谁绑谁,不用的不要绑定。3. 代码正确但因版本问题无法运行:删除命名空间,并将后面对应部分改为public partial class Default : Page。4. 注意控件的一致性:.aspx设计选项卡中的控件名=.aspx源选项卡中的控件标识名=.aspx.cs中的控件名。5. 注意每个.aspx文件源选项卡中的第一行:的匹配问题。6. DropDownList无法回送数据:将DropDwonList中的AutoPostBack选中。八、实验总结通过本次实验,我熟悉了VS环

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论