ASP NET动态网站开发基础教程习题答案(5)

2019-01-19 13:20

价格:

标题:

              

ex8_3.aspx.cs的源代码如下所示。

public partial class ex8_3 : System.Web.UI.Page {

protected void Button1_Click(object sender, EventArgs e) {

string xml = Server.MapPath(\XElement root = XElement.Load(xml);

System.Collections.Generic.IEnumerable address = from el in root.Elements(\

where (string)el.Attribute(\select el;

foreach (XElement el in address) {

el.Attribute(\el.Attribute(\}

root.Save(xml); } }

Chap09参考答案 一、填空题

1. ContentPlaceHolder ContentPlaceHolder 内容页 2. 公共成员 控件

3. 站点地图 ASP.NET控件 代码

4. 其他站点地图提供程序 其他站点地图文件 该站点的其他目录 同一应用程序中的其他站点。 二、选择题

1.C 2.A 3.AD 4、A 5、C 三、上机操作题

1.Default.aspx的源代码如下所示: <%@ Page Language=\AutoEventWireup=\

CodeFile=\

Inherits=\

无标题页

2.Default.aspx的源代码如下所示: <%@ Page Language=\AutoEventWireup=\CodeFile=\Inherits=\无标题页

3.母版页MasterPage_Load.master.cs的源代码如下:

public partial class MasterPage_Load : System.Web.UI.MasterPage {

protected void Page_Load(object sender, EventArgs e) {

Response.Write(\初始化母版页');\} }

内容页Home_Load.aspx.cs的源代码如下:

public partial class Home_Load : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

Response.Write(\初始化内容页');\} }

Chap10参考答案 一、填空题 1、HTTP 2、XML 3、XML

4、信息注册 5、交互 二、选择题

1、ABC 2、ABCD 3、ABC 4、ABCD 5、ABCD 三、上机操作题

1、在Service.cs文件中的代码如下:

[WebService(Namespace = \

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService {

public Service () {

//如果使用设计的组件,请取消注释以下行 //InitializeComponent(); }

[WebMethod]

public int add(int a,int b) { return a + b;

} }

2、在Default.aspx文件中的代码如下:

在Default.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) {

Service1.Service ws = new Service1.Service(); TextBox3.Text = ws.add(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text)).ToString(); } }

3、在Service.cs文件中加入如下代码: [WebMethod]

public bool GetBook(out DataSet ds) {

String sqlconn = \.NET3.5动态网站开发基础教程\\\\代码\\\\chap10Ex\\\\ServiceEx\\\\App_Data\\\\BookStore.mdb;\OleDbConnection myConnection = new OleDbConnection(sqlconn); myConnection.Open();

OleDbDataAdapter myCommand = new OleDbDataAdapter(\ds = new DataSet(); myCommand.Fill(ds); return true; }

在该网站中添加一个名为DisplayBook.aspx的文件,在该文件中加入一个GridView控件,然后在DisplayBook.aspx.cs的Page_Load函数中加入如下代码: protected void Page_Load(object sender, EventArgs e) {

ServiceEx.Service svr = new ServiceEx.Service(); DataSet ds = new DataSet(); if(svr.GetBook(out ds)) {

GridView1.DataSource = ds; GridView1.DataBind(); } }

Chap11参考答案 一.填空题

1. 2. Name LoginUrl Protection TimeOut

3. Session_Start Session Session.Abandon Session.End 4. Glabal.asax HttpApplication Application_Start Application_EndRequest Application_End 二、选择题

1. ABCD 2.BCD 3.D 4. AD

Application_BeginRequest

三、上机实习题

1.Web.config里面连接信息的内容为:

Default.aspx.cs的内容为:

public partial class _Default : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

Configuration rootWebConfig = WebConfigurationManager.OpenWebConfiguration(\ConnectionStringSettings connString;

if (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count) {

connString = rootWebConfig.ConnectionStrings.ConnectionStrings[1]; if (connString.ConnectionString != \{

OleDbConnection myConnection = new OleDbConnection(connString.ConnectionString); myConnection.Open();

OleDbDataAdapter myCommand = new OleDbDataAdapter(\DataSet ds = new DataSet(); myCommand.Fill(ds);

GridView1.DataSource = new DataView(ds.Tables[0]); GridView1.DataBind(); }

} } }

2. ChooseAuthor.aspx.cs的代码为:

public partial class ChooseAuthor : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

Label1.Text = Application[\}

protected void Button1_Click(object sender, EventArgs e) {

Session[\

Response.Redirect(\} }

DisplayWorks.aspx.cs的代码为:

public partial class DisplayWorks : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

Configuration rootWebConfig = WebConfigurationManager.OpenWebConfiguration(\//声明ConnectionStringSettings对象 ConnectionStringSettings connString;

//如果连接字符串大于0则继续查找连接信息,否则返回Nothing if (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count) {

Label1.Text = Session[\

connString = rootWebConfig.ConnectionStrings.ConnectionStrings[1]; //得到连接信息

if (connString.ConnectionString != \{

SqlConnection myConnection = new SqlConnection(connString.ConnectionString); myConnection.Open();

string strSel = \作者 = '\SqlDataAdapter myCommand = new SqlDataAdapter(strSel, myConnection); DataSet ds = new DataSet(); myCommand.Fill(ds);

GridView1.DataSource = new DataView(ds.Tables[0]); GridView1.DataBind(); } }


ASP NET动态网站开发基础教程习题答案(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2010年下半年中国银行业从业人员资格认证考试--真题&答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: