




已阅读5页,还剩39页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Chap01参考答案一、填空题1、Web XML Web services2、公共语言运行库、.NET Framework类库3、属性 方法 事件4、aspx5、cs二、选择题1、ABCD 2、ABCD 3、AB 4、A 5、B三、上机操作题1、参考1.3.1。2、参考1.4.2。3、在ex1_1.aspx文件中的代码如下所示: 在ex1_1.aspx.cs中的代码如下所示:public partial class _Default : System.Web.UI.Page private static int i; protected void Page_Load(object sender, EventArgs e) if(!Page.IsPostBack) i = 0; protected void Button1_Click(object sender, EventArgs e) i=i+1; Label1.Text = 您单击了+i.ToString()+次按钮; Chap02参考答案一、填空题1、引用类型2、object3、显式4、多态性5、初始化语句右侧二、选择题1、AC 2、A 3、B 4、B 5、AC三、上机操作题1、本习题的源代码如下:namespace ex2_1 struct student public string name; public string address; public string tel; ; class Program static void Main(string args) student stu = new student5; for (int i = 0; i 5; i+) = Console.ReadLine(); stui.address = Console.ReadLine(); stui.tel = Console.ReadLine(); for (int i = 0; i 5; i+) Console.WriteLine(i.ToString(); Console.WriteLine(); Console.WriteLine(stui.address); Console.WriteLine(stui.tel); Console.ReadLine(); 2、本习题的源代码如下:namespace ex2_2 class Program static void sort(int a, int n) int temp; for (int i = 1; i n; i+) for (int j = 0; j aj + 1) temp = aj; aj = aj + 1; aj + 1 = temp; static void Main(string args) int n = 5; int a = new int5; for (int i = 0; i 5; i+) ai = Convert.ToInt32(Console.ReadLine(); sort(a, n); for (int i = 0; i 5; i+) Console.WriteLine(ai.ToString(); Console.ReadLine(); 3、本习题的源代码如下:namespace ex2_3 class student protected string m_name; protected string m_sex; protected float m_tuition; public student(string strname, string strsex, float ftuition) m_name = strname; m_sex = strsex; m_tuition = ftuition; virtual public void printfInfo() Console.WriteLine(m_name + + m_sex + + m_tuition.ToString(); class graduate : student protected string m_tutor; public graduate(string strname, string strsex, float ftuition,string strtutor):base(strname,strsex,ftuition) m_tutor = strtutor; override public void printfInfo() base.printfInfo(); Console.WriteLine(导师是+m_tutor); class Program static void Main(string args) student s = new student(张三, 男, 5000); graduate g = new graduate(李四, 女, 9000, 王五); s.printfInfo(); g.printfInfo(); Console.ReadLine(); Chap03参考答案一、填空题1、HttpResponse2、客户端3、服务器4、状态变量5、用户会话二、选择题1、C 2、ABCD 3、ABCD 4、AD三、上机操作题1、在ex_1_1.aspx文件中的代码如下所示: 在ex_1_1.aspx.cs文件中的代码如下所示:public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) Response.Redirect(ex_1_2.aspx?name=张三); 在ex_1_2.aspx.cs文件中的代码如下所示:public partial class ex_1_2 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) Response.Write(Request.QueryStringname); 2、在ex2_1.aspx文件中的代码如下所示: 在ex_2_1.aspx.cs文件中的代码如下所示:public partial class _ex_2_1 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) Sessionname = 李四; Response.Redirect(ex_2_2.aspx); 在ex_2_2.aspx文件中的代码如下所示: 在ex_2_2.aspx.cs文件中的代码如下所示:public partial class _ex_2_2 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) Label1.Text = Sessionname.ToString(); 3、在ex_3_1.aspx.cs文件中的代码如下所示:public partial class _ex_3_1 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) HttpCookie cookie1 = Request.Cookiesttt; if (cookie1 = null) /创建一个cookie实例 HttpCookie cookie = new HttpCookie(ttt); /添加要存储的信息,采用键/值结合的方式 cookie.Values.Add(Name, Tom); cookie.Expires = DateTime.Now.AddYears(1); /把cookie加如当前的页面的Response对象里面 Response.Cookies.Add(cookie); Response.Redirect(); else Response.Write(cookie1.ValuesName); Chap04参考答案一、填空题1、System.Web.UI.WebControls2设置是否自动向服务器发送数据 false用户单击此控件时并不导致向服务器发送页面。3编程方式 运行时更改页面中的文本4标头 标题 链接 链接5图像 作用点控件的集合二、1D 2.B 3.D 4.C 5.D三、上机操作题1、在ex4_1.aspx文件中代码如下所示: 演示ComboBox控件的使用 请选择您的登录方式: 系统管理员 高级用户 普通用户 游客 您选择的登录方式为: ex4_1.aspx.cs的代码如下所示:public partial class ex4_1 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void DisplayType(object sender, EventArgs e) Label1.Text = DropDownList1.Text; 2、在ex4_2.aspx文件中代码如下所示: 日期选择 ex4_2.aspx.cs的代码如下所示:public partial class ex4_2 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) if (!e.Day.IsOtherMonth & !e.Day.IsWeekend) e.Cell.BackColor = System.Drawing.Color.Yellow; else if (!e.Day.IsOtherMonth & e.Day.IsWeekend) e.Cell.BackColor = System.Drawing.Color.Red; e.Day.IsSelectable = false; 3、在ex4_3.aspx文件中代码如下所示: 请选择您最喜欢的网站 百度 谷歌 新浪 您最喜欢的网站是: 在ex4_3.aspx.cs文件中代码如下所示:public partial class ex4_3 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void ItemsBulletedList_Click(object sender, BulletedListEventArgs e) switch (e.Index) case 0: Label1.Text = 百度; break; case 1: Label1.Text = 谷歌; break; case 2: Label1.Text = 新浪; break; Chap05参考答案一、填空题1、客户端数据验证 服务器端数据验证2、RequiredFieldValidator3、CompareValidator4、RegularExpressionValidator5、.ascx二、1D 2. D 3.ABCD 4、C 5、AB三、上机操作题1、ex5_1.aspx的源代码如下: 数字输入 请输入: 2、ex5_2.aspx的源代码如下: 判断日期 请输入日期: 3、身份验证用户控件的源代码如下:ex5_3.aspx的源代码如下: 输入身份证号码 请输入您的身份证号码: Chap06 参考答案一、1Connection Command DataSetCommand DataSet DataReader 2数据处理 Connection Command DataReader DataAdapter 3User ID(uid) Password(pwd) 用户ID 口令 4SqlDataSource ACCESS 密码 ACCESS 5数据命令 数据库连接 填充 DataSet 更新数据源 DataSet二、1B 2.AC 3.A 4.A 5.ABCD三、上机操作题1、ex6_1.aspx.cs的源代码如下:protected void Page_Load(object sender, EventArgs e) String sqlconn = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:Databaseasp3.5BasicBookStore.mdb; OleDbConnection myConnection = new OleDbConnection(sqlconn); myConnection.Open(); OleDbCommand myCommand = new OleDbCommand(select * from Book, myConnection); OleDbDataReader myReader; myReader = myCommand.ExecuteReader(); Response.Write(使用OleDbCommand类读取数据); Response.Write(); Response.Write(); for (int i = 0; i myReader.FieldCount; i+) Response.Write( + myReader.GetName(i) + ); Response.Write(); while (myReader.Read() Response.Write(); for (int i = 0; i myReader.FieldCount; i+) Response.Write( + myReaderi.ToString() + ); Response.Write(); Response.Write(); myReader.Close(); myConnection.Close(); 2、ex6_2.aspx的源代码如下: 使用DataApapter读取Access数据库 使用数据适配器 Ex6_2.aspx.cs的主要代码如下: protected void Page_Load(object sender, EventArgs e) string ConnectionStr = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= E:Databaseasp3.5BasicBookStore.mdb ; OleDbConnection myConn = new OleDbConnection(ConnectionStr); myConn.Open(); OleDbCommand myCommand = new OleDbCommand(select * from Book, myConn); OleDbDataAdapter Adapter = new OleDbDataAdapter(); Adapter.SelectCommand = myCommand; DataSet myDs = new DataSet(); Adapter.Fill(myDs); GridView1.DataSource = myDs.Tables0.DefaultView; GridView1.DataBind(); myConn.Close(); 3、ex6_3.aspx.cs的主要代码如下:public partial class ex6_3 : System.Web.UI.Page void CreateXmlDocument(string file) XmlDocument doc = new XmlDocument(); XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration(1.0, utf-8, null); doc.InsertBefore(xmlDeclaration, doc.DocumentElement); XmlElement rootNode = doc.CreateElement(books); doc.AppendChild(rootNode); XmlElement parentNode = doc.CreateElement(book); XmlElement title = doc.CreateElement(title); XmlText strTitle = doc.CreateTextNode(ASP.NET入门); title.AppendChild(strTitle); parentNode.AppendChild(title); XmlElement author = doc.CreateElement(author); XmlText txtAuth = doc.CreateTextNode(张三); author.AppendChild(txtAuth); parentNode.AppendChild(author); doc.DocumentElement.PrependChild(parentNode); XmlElement parentNode = doc.CreateElement(book); XmlElement title = doc.CreateElement(title); XmlText strTitle = doc.CreateTextNode(ASP.NET精通); title.AppendChild(strTitle); parentNode.AppendChild(title); XmlElement author = doc.CreateElement(author); XmlText txtAuth = doc.CreateTextNode(李四); author.AppendChild(txtAuth); parentNode.AppendChild(author); doc.DocumentElement.PrependChild(parentNode); doc.Save(Server.MapPath(file);
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 爬架安全专业试题及答案
- 口腔专业基础试题及答案
- 卫生应急专业试题及答案
- 湖北省孝感市2025-2026学年高二上学期9月起点考试物理试卷(含答案)
- 黑龙江省大庆市2025-2026学年高三第一次教学质量检测数学试题(含答案)
- 专业级试题及答案
- 历史专业期末试题及答案
- 广东省2025-2026年高三上9月月考历史试卷(含答案)
- 福建省泉州市安溪县2024-2025学年高二上学期11月期中考试化学试卷(含答案)
- 龙岗玻璃锁施工方案
- 光刻技术简介
- 《电磁学》教案课件
- GB/T 4291-1999冰晶石
- 机修车间岗位廉洁风险点及防范措施表
- 全新版尹定邦设计学概论1课件
- 牙及牙槽外科
- 文物建筑保护修缮专项方案
- 万用表 钳形表 摇表的使用课件
- 63T折弯机使用说明书
- 170位真实有效投资人邮箱
- 工程力学ppt课件(完整版)
评论
0/150
提交评论