70562 questions

49
[email protected] (IT Chanakya) TS: Microsoft .NET Framework 3.5, ASP.NET Application Development C#

Upload: pragya-rastogi

Post on 07-Nov-2014

989 views

Category:

Technology


6 download

DESCRIPTION

 

TRANSCRIPT

Page 1: 70562 Questions

[email protected] (IT Chanakya)

TS: Microsoft .NET Framework 3.5, ASP.NET Application Development C#

Page 2: 70562 Questions

[email protected] (IT Chanakya)

Exam A

QUESTION 1You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web page that contains the following two XML fragments. (Line numbers are included forreference only.) 01 <script runat="server"> 02 03 </script> 04 <asp:ListView ID="ListView1" runat="server" 05 DataSourceID="SqlDataSource1" 06 07 > 08 <ItemTemplate> 09 <td> 10 <asp:Label ID="LineTotalLabel" runat="server" 11 Text='<%# Eval("LineTotal") %>' /> 12 </td> 13 </ItemTemplate> The SqlDataSource1 object retrieves the data from a Microsoft SQL Server 2005 database table. Thedatabase table has a column named LineTotal.You need to ensure that when the size of the LineTotal column value is greater than seven characters, thecolumn is displayed in red color.What should you do?

A. Insert the following code segment at line 06.OnItemDataBound="FmtClr" Insert the following code segment at line 02.protected void FmtClr (object sender, ListViewItemEventArgs e) {Label LineTotal = (Label)e.Item.FindControl("LineTotalLabel"); if ( LineTotal.Text.Length > 7) { LineTotal.ForeColor = Color.Red; } else { LineTotal.ForeColor = Color.Black; } }

B. Insert the following code segment at line 06.OnItemDataBound="FmtClr" Insert the following code segment at line 02.protected void FmtClr (object sender, ListViewItemEventArgs e) {Label LineTotal = (Label)e.Item.FindControl("LineTotal"); if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }

C. Insert the following code segment at line 06.OnDataBinding="FmtClr" Insert the following code segment at line 02.protected void FmtClr(object sender, EventArgs e) {Label LineTotal = new Label(); LineTotal.ID = "LineTotal"; if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else { LineTotal.ForeColor = Color.Black; } }

Page 3: 70562 Questions

[email protected] (IT Chanakya)

D. Insert the following code segment at line 06.OnDataBound="FmtClr" Insert the following code segment at line 02.protected void FmtClr(object sender, EventArgs e) {Label LineTotal = new Label(); LineTotal.ID = "LineTotalLabel"; if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }

Answer: AExplanation/Reference:

QUESTION 2You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web form and add the following code fragment.<asp:Repeater ID="rptData" runat="server"DataSourceID="SqlDataSource1"ItemDataBound="rptData_ItemDataBound"> <ItemTemplate> <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("QuantityOnHand") %>' /> </ItemTemplate> </asp:Repeater> The SqlDataSource1 DataSource control retrieves the Quantity column values from a table named Products.You write the following code segment to create the rptData_ItemDataBound event handler.(Line numbers are included for reference only.) 01 protected void rptData_ItemDataBound(object sender, 02 RepeaterItemEventArgs e) 03 { 04 05 if(lbl != null) 06 if(int.Parse(lbl.Text) < 10) 07 lbl.ForeColor = Color.Red; 08 } You need to retrieve a reference to the lblQuantity Label control into a variable named lbl.Which code segment should you insert at line 04?

A. Label lbl = Page.FindControl("lblQuantity") as Label;B. Label lbl = e.Item.FindControl("lblQuantity") as Label;C. Label lbl = rptData.FindControl("lblQuantity") as Label;D. Label lbl = e.Item.Parent.FindControl("lblQuantity") as Label;

Answer: BExplanation/Reference:

QUESTION 3You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.Your application has a user control named UserCtrl.ascx. You write the following code fragment to create aWeb page named Default.aspx.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <html> ...<body>

Page 4: 70562 Questions

[email protected] (IT Chanakya)

<form id="form1" runat="server"> <div> <asp:Label ID="lblHeader" runat="server"></asp:Label> <asp:Label ID="lbFooter" runat="server"></asp:Label> </div> </form> </body> </html> You need to dynamically add the UserCtrl.ascx control between the lblHeader and lblFooter Label controls.What should you do?

A. Write the following code segment in the Init event of the Default.aspx Web page.Control ctrl = LoadControl("UserCtrl.ascx"); this.Controls.AddAt(1, ctrl);

B. Write the following code segment in the Init event of the Default.aspx Web page.Control ctrl = LoadControl("UserCtrl.ascx"); lblHeader.Controls.Add(ctrl);

C. Add a Literal control named Ltrl between the lblHeader and lblFooter label controls.Write the following code segment in the Init event of the Default.aspx Web page.Control ctrl = LoadControl("UserCtrl.ascx");

D. Add a PlaceHolder control named PlHldr between the lblHeader and lblFooter label controls.Write the following code segment in the Init event of the Default.aspx Web page.Control ctrl = LoadControl("UserCtrl.ascx"); PlHldr.Controls.Add(ctrl);

Answer: DExplanation/Reference:

QUESTION 4You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create two user controls named UserCtrlA.ascx and UserCtrlB.ascx. The user controls postback to theserver.You create a new Web page that has the following ASPX code.<asp:CheckBox ID="Chk" runat="server" oncheckedchanged="Chk_CheckedChanged" AutoPostBack="true" /> <asp:PlaceHolder ID="PlHolder" runat="server"></asp:PlaceHolder> To dynamically create the user controls, you write the following code segment for the Web page.

public void LoadControls() {if (ViewState["CtrlA"] != null) {

Control c; if ((bool)ViewState["CtrlA"] == true) { c = LoadControl("UserCtrlA.ascx"); } else { c = LoadControl("UserCtrlB.ascx"); }

c.ID = "Ctrl"; PlHolder.Controls.Add(c); }

}

protected void Chk_CheckedChanged(object sender, EventArgs e) { ViewState["CtrlA"] = Chk.Checked; PlHolder.Controls.Clear(); LoadControls(); }You need to ensure that the user control that is displayed meets the following requirements:It is recreated during postback It retains its state.

Page 5: 70562 Questions

[email protected] (IT Chanakya)

Which method should you add to the Web page?

A. protected override object SaveViewState() {LoadControls(); return base.SaveViewState(); }

B. protected override void Render(HtmlTextWriter writer) {LoadControls(); base.Render(writer); }

C. protected override void OnLoadComplete(EventArgs e) {base.OnLoadComplete(e); LoadControls(); }

D. protected override void LoadViewState(object savedState) {base.LoadViewState(savedState); LoadControls(); }

Answer: DExplanation/Reference:

QUESTION 5You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create the following controls:A composite custom control named MyControl.A templated custom control named OrderFormData.You write the following code segment to override the method named CreateChildControls() in the MyControlclass. (Line numbers are included for reference only.) 01 protected override void 02 CreateChildControls() { 03 Controls.Clear(); 04 OrderFormData oFData = new 05 OrderFormData("OrderForm"); 06 07 } You need to add the OrderFormData control to the MyControl control.Which code segment should you insert at line 06?

A. Template.InstantiateIn(this); this.Controls.Add(oFData);B. Template.InstantiateIn(oFData); Controls.Add(oFData); C. this.TemplateControl = (TemplateControl)Template; -Can't Remember All-???

oFData.TemplateControl = (TemplateControl)Template; Controls.Add(oFData);

D. this.TemplateControl = (TemplateControl)oFData; -Can't Remember All-???Controls.Add(oFData);

Answer: BExplanation/Reference:

QUESTION 6You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a composite custom control named MyControl.You need to add an instance of the OrderFormData control to the MyControl control.Which code segment should you use?

Page 6: 70562 Questions

[email protected] (IT Chanakya)

A. protected override void CreateChildControls() { Controls.Clear(); OrderFormData oFData = new OrderFormData("OrderForm"); Controls.Add(oFData); }

B. protected override void RenderContents(HtmlTextWriter writer) { OrderFormData oFData = new OrderFormData("OrderForm"); oFData.RenderControl(writer); }

C. protected override void EnsureChildControls() { Controls.Clear(); OrderFormData oFData = new OrderFormData("OrderForm"); oFData.EnsureChildControls(); if (!ChildControlsCreated) CreateChildControls(); }

D. protected override ControlCollection CreateControlCollection() { ControlCollection controls = new ControlCollection(this); OrderFormData oFData = new OrderFormData("OrderForm"); controls.Add(oFData); return controls; }

Answer: AExplanation/Reference:

QUESTION 7You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a custom control named OrderForm.You write the following code segment.public delegate void CheckOrderFormEventHandler(EventArgs e); private static readonly objectCheckOrderFormKey = new object(); public event CheckOrderFormEventHandler CheckOrderForm { add { Events.AddHandler(CheckOrderFormKey, value); }remove { Events.RemoveHandler(CheckOrderFormKey, value); }} You need to provide a method that enables the OrderForm control to raise the CheckOrderForm event.Which code segment should you use?

A. protected virtual void OnCheckOrderForm(EventArgs e) { CheckOrderFormEventHandler checkOrderForm = (CheckOrderFormEventHandler)Events[ typeof(CheckOrderFormEventHandler)]; if (checkOrderForm != null) checkOrderForm(e); }

B. protected virtual void OnCheckOrderForm(EventArgs e) { CheckOrderFormEventHandler checkOrderForm = Events[CheckOrderFormKey] asCheckOrderFormEventHandler; if (checkOrderForm != null) checkOrderForm(e); }

C. CheckOrderFormEventHandler checkOrderForm = new CheckOrderFormEventHandler(checkOrderFormCallBack); protected virtual void OnCheckOrderForm(EventArgs e) { if (checkOrderForm != null) checkOrderForm(e); }

Page 7: 70562 Questions

[email protected] (IT Chanakya)

D. CheckOrderFormEventHandler checkOrderForm = new CheckOrderFormEventHandler(checkOrderFormCallBack); protected virtual void OnCheckOrderForm(EventArgs e) { if (checkOrderForm != null) RaiseBubbleEvent(checkOrderForm, e); }

Answer: BExplanation/Reference:

QUESTION 8You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You add a TextBox control named TextBox1.You write the following code segment for validation.

protected void CustomValidator1_ServerValidate( object source, ServerValidateEventArgs args) { DateTime dt = String.IsNullOrEmpty(args.Value) DateTime.Now : Convert.ToDateTime(args.Value); args.IsValid = (DateTime.Now - dt).Days < 10; }

You need to validate the value of TextBox1.Which code fragment should you add to the Web page?

A. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator><asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date" EnableClientScript="true"ControlToValidate="TextBox1" Operator="DataTypeCheck" > </asp:CompareValidator>

B. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"ControlToValidate="TextBox1"InitialValue="<%= DateTime.Now; %>" > </asp:RequiredFieldValidator>

C. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator><asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date" EnableClientScript="true"ControlToValidate="TextBox1" ValueToCompare="<%= DateTime.Now; %>"> </asp:CompareValidator>

D. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"EnableClientScript="false" InitialValue="<%= DateTime.Now; %>" > </asp:RequiredFieldValidator>

Answer: AExplanation/Reference:

QUESTION 9You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You derive a new validation control from the BaseValidator class.

Page 8: 70562 Questions

[email protected] (IT Chanakya)

The validation logic for the control is implemented in the Validate method in the following manner.protected static bool Validate(string value) { ...} You need to override the method that validates the value of the related control.Which override method should you use?

A. protected override bool EvaluateIsValid() { string value = GetControlValidationValue( this.Attributes["AssociatedControl"]); bool isValid = Validate(value); return isValid; }

B. protected override bool ControlPropertiesValid() { string value = GetControlValidationValue(this.ValidationGroup); bool isValid = Validate(value); return isValid; }

C. protected override bool EvaluateIsValid() { string value = GetControlValidationValue(this.ControlToValidate); bool isValid = Validate(value); return isValid; }

D. protected override bool ControlPropertiesValid() { string value = GetControlValidationValue( this.Attributes["ControlToValidate"]); bool isValid = Validate(value); this.PropertiesValid = isValid; return true; }

Answer: C

QUESTION 10You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You add an XmlDataSource control named XmlDataSource1 to the Web page.XmlDataSource1 is bound to an XML document with the following structure.<?xml version="1.0" encoding="utf-8" ?> <clients> <client ID="1" Name="John Evans" /> <client ID="2" Name="Mike Miller"/> ...</clients> You also write the following code segment in the code-behind file of the Web page.protected void BulletedList1_Click( ?object sender, BulletedListEventArgs e) { //...} You need to add a BulletedList control named BulletedList1 to the Web page that is bound toXmlDataSource1.Which code fragment should you use?

A. <asp:BulletedList ID="BulletedList1" runat="server" DisplayMode="LinkButton"DataSource="XmlDataSource1" DataTextField="Name" DataValueField="ID"onclick="BulletedList1_Click"> </asp:BulletedList>

B. <asp:BulletedList ID="BulletedList1" runat="server" DisplayMode="HyperLink"DataSourceID="XmlDataSource1" DataTextField="Name" DataMember="ID"onclick="BulletedList1_Click"> </asp:BulletedList>

C. <asp:BulletedList ID="BulletedList1" runat="server" DisplayMode="LinkButton"DataSourceID="XmlDataSource1" DataTextField="Name" DataValueField="ID"onclick="BulletedList1_Click"> </asp:BulletedList>

D. <asp:BulletedList ID="BulletedList1" runat="server" DisplayMode="HyperLink"DataSourceID="XmlDataSource1" DataTextField="ID" DataValueField="Name"onclick="BulletedList1_Click"> </asp:BulletedList>

Answer: CExplanation/Reference:

QUESTION 11You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code fragment.<asp:ListBox SelectionMode="Multiple" ID="ListBox1" runat="server"> </asp:ListBox> <asp:ListBox ID="ListBox2" runat="server"> </asp:ListBox>

Page 9: 70562 Questions

[email protected] (IT Chanakya)

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> You need to ensure that when you click the Button1 control, a selected list of items move from the ListBox1control to the ListBox2 control.Which code segment should you use?

A. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { ListBox2.Items.Add(li); ListBox1.Items.Remove(li); }}

B. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { li.Selected = false; ListBox2.Items.Add(li);ListBox1.Items.Remove(li); }}

C. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { li.Selected = false; ListBox2.Items.Add(li); }}

D. foreach (ListItem li in ListBox2.Items) { if (ListBox1.Items.Contains(li)) ListBox1.Items.Remove(li); }E. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { ListBox1.Items.Remove(li); }

}F. foreach (ListItem li in ListBox1.Items) { if (ListBox2.Items.Contains(li)) ListBox1.Items.Remove(li); }

Answer: CDExplanation/Reference:

QUESTION 12You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code fragment.<asp:DropDownList AutoPostBack="true" ID="DropDownList1" runat="server" onselectedindexchanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:DropDownList> You also add a MultiView control named MultiView1 to the Web page. MultiView1 has three child Viewcontrols.You need to ensure that you can select the View controls by using the DropDownList1 DropDownList control.Which code segment should you use?

A. int idx = DropDownList1.SelectedIndex; MultiView1.ActiveViewIndex = idx;B. int idx = DropDownList1.SelectedIndex; MultiView1.Views[idx].Visible = true;C. int idx = int.Parse(DropDownList1.SelectedValue); MultiView1.ActiveViewIndex = idx;D. int idx = int.Parse(DropDownList1.SelectedValue); MultiView1.Views[idx].Visible = true;

Answer: AExplanation/Reference:ActiveViewIndex is Zero base Index.

QUESTION 13You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.To add a Calendar server control to a Web page, you write the following code fragment.<asp:Calendar SelectionMode="DayWeek" ID="Calendar1" runat="server"> </asp:Calendar> You need to disable the non-week days in the Calendar control.What should you do?

Page 10: 70562 Questions

[email protected] (IT Chanakya)

A. Add the following code segment to the Calendar1 DayRender event handler.if (e.Day.IsWeekend) { Day.IsSelectable = false; }

B. Add the following code segment to the Calendar1 DayRender event handler.if (e.Day.IsWeekend) { if (Calendar1.SelectedDates.Contains(e.Day.Date)) Calendar1.SelectedDates.Remove(e.Day.Date); }

C. Add the following code segment to the Calendar1 SelectionChanged event handler.List<DateTime> list = new List<DateTime>(); foreach (DateTime st in (sender as Calendar).SelectedDates) { if (st.DayOfWeek == DayOfWeek.Saturday || st.DayOfWeek == DayOfWeek.Sunday) { list.Add(st); }}

foreach (DateTime dt in list) { (sender as Calendar).SelectedDates.Remove(dt); }

D. Add the following code segment to the Calendar1 DataBinding event handler.List<DateTime> list = new List<DateTime>(); foreach (DateTime st in (sender as Calendar).SelectedDates) { if (st.DayOfWeek == DayOfWeek.Saturday || st.DayOfWeek == DayOfWeek.Sunday) { list.Add(st); }} foreach (DateTime dt in list) { (sender as Calendar).SelectedDates.Remove(dt); }

Answer: AExplanation/Reference:

QUESTION 14You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You define the following class.public class Product { public decimal Price { get; set; } }

Your application contains a Web form with a Label control named lblPrice.You use a StringReader variable named xmlStream to access the following XML fragment.<Product> <Price>35</Price> </Product> You need to display the price of the product from the XML fragment in the lblPrice Label control.Which code segment should you use?

A. DataTable dt = new DataTable(); dt.ExtendedProperties.Add("Type", "Product"); dt.ReadXml(xmlStream); lblPrice.Text = dt.Rows[0]["Price"].ToString();

Page 11: 70562 Questions

[email protected] (IT Chanakya)

B. XmlReader xr = XmlReader.Create(xmlStream); Product boughtProduct = xr.ReadContentAs(typeof(Product), null) as Product; lblPrice.Text = boughtProduct.Price.ToString();

C. XmlSerializer xs = new XmlSerializer(typeof(Product)); Product boughtProduct = xs.Deserialize(xmlStream) as Product; lblPrice.Text = boughtProduct.Price.ToString();

D. XmlDocument xDoc = new XmlDocument(); xDoc.Load(xmlStream); Product boughtProduct = xDoc.OfType<Product>().First(); lblPrice.Text = boughtProduct.Price.ToString();

Answer: CExplanation/Reference:

QUESTION 15You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You add a Web form that contains the following code fragment.<asp:GridView ID="gvProducts" runat="server" AllowSorting="True" DataSourceID="Products"> </asp:GridView> <asp:ObjectDataSource ID="Products" runat="server" SelectMethod="GetData" TypeName="DAL" /> </asp:ObjectDataSource>

You write the following code segment for the GetData method of the DAL class. (Line numbers are includedfor reference only.) 01 public object GetData() { 02 SqlConnection cnn = new SqlConnection( ) 03 string strQuery = "SELECT * FROM Products"; 04 05 } You need to ensure that the user can use the sorting functionality of the gvProducts GridView control.Which code segment should you insert at line 04?

A. SqlCommand cmd = new SqlCommand(strQuery, cnn); cnn.Open(); return cmd.ExecuteReader();

B. SqlCommand cmd = new SqlCommand(strQuery, cnn); cnn.Open(); return cmd.ExecuteReader(CommandBehavior.KeyInfo);

C. SqlDataAdapter da = new SqlDataAdapter(strQuery, cnn); DataSet ds = new DataSet(); da.Fill(ds); return ds;

D. SqlDataAdapter da = new SqlDataAdapter(strQuery, cnn); DataSet ds = new DataSet(); da.Fill(ds); ds.ExtendedProperties.Add("Sortable", true); return ds.Tables[0].Select();

Answer: CExplanation/Reference:

QUESTION 16You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.

Page 12: 70562 Questions

[email protected] (IT Chanakya)

You create a class that contains the following code segment. (Line numbers are included for reference only.) 01 public object GetCachedProducts(sqlConnection conn) { 02 03 if (Cache["products"] == null) { 04 SqlCommand cmd = new SqlCommand( 05 "SELECT * FROM Products", conn); 07 conn.Open(); 08 Cache.Insert("products", GetData(cmd)); 09 conn.Close(); 10 } 11 return Cache["products"]; 12 } 13 14 public object GetData(SqlCommand prodCmd) { 15 16 } Each time a Web form has to access a list of products, the GetCachedProducts method is called to providethis list from the Cache object.You need to ensure that the list of products is always available in the Cache object.Which code segment should you insert at line 15?

A. return prodCmd.ExecuteReader(); SqlDataReader dr; prodCmd.CommandTimeout = int.MaxValue;

B. dr = prodCmd.ExecuteReader(); return dr;

C. SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = prodCmd; DataSet ds = new DataSet(); return ds.Tables[0];

D. SqlDataAdapter da = new SqlDataAdapter(prodCmd); DataSet ds = new DataSet(); da.Fill(ds); return ds;

Answer: DExplanation/Reference:

QUESTION 17You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code segment in the code-behind file to create a Web form. (Line numbers areincluded for reference only.) 01 string strQuery = "select * from Products;" 02 + "select * from Categories"; 03 SqlCommand cmd = new SqlCommand(strQuery, cnn); 04 cnn.Open(); 05 SqlDataReader rdr = cmd.ExecuteReader(); 06 07 rdr.Close(); 08 cnn.Close(); You need to ensure that the gvProducts and gvCategories GridView controls display the data that is containedin the following two database tables:The Products database tabl The Categories database tabl Which code segment should you insert at line 06?

Page 13: 70562 Questions

[email protected] (IT Chanakya)

A. gvProducts.DataSource = rdr; gvProducts.DataBind(); gvCategories.DataSource = rdr; gvCategories.DataBind();

B. gvProducts.DataSource = rdr; gvCategories.DataSource = rdr; gvProducts.DataBind(); gvCategories.DataBind();

C. gvProducts.DataSource = rdr; rdr.NextResult(); gvCategories.DataSource = rdr; gvProducts.DataBind(); gvCategories.DataBind();

D. gvProducts.DataSource = rdr; gvCategories.DataSource = rdr; gvProducts.DataBind(); rdr.NextResult(); gvCategories.DataBind();

Answer: DExplanation/Reference:

QUESTION 18You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web form that contains the following code fragment.<asp:TextBox runat="server" ID="txtSearch" /> <asp:Button runat="server" ID="btnSearch" Text="Search" OnClick="btnSearch_Click" /> <asp:GridView runat="server" ID="gridCities" /> You write the following code segment in the code-behind file. (Line numbers are included for reference only.) 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 DataSet objDS = new DataSet(); 04 SqlDataAdapter objDA = new SqlDataAdapter(objCmd); 05 objDA.Fill(objDS); 06 gridCities.DataSource = objDs; 07 gridCities.DataBind(); 08 Session["ds"] = objDS; 09 } 10 protected void btnSearch_Click(object sender, EventArgs e) 11 { 12 13 } You need to ensure that when the btnSearch Button control is clicked, the records in the gridCities GridViewcontrol are filtered by using the value of the txtSearch TextBox.Which code segment you should insert at line 12?

A. DataSet ds = gridCities.DataSource as DataSet; DataView dv = ds.Tables[0].DefaultView; dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'"; gridCities.DataSource = dv; gridCities.DataBind();

Page 14: 70562 Questions

[email protected] (IT Chanakya)

B. DataSet ds = Session["ds"] as DataSet; DataView dv = ds.Tables[0].DefaultView; dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'"; gridCities.DataSource = dv; gridCities.DataBind();

C. DataTable dt = Session["ds"] as DataTable; DataView dv = dt.DefaultView; dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'"; gridCities.DataSource = dv; gridCities.DataBind();

D. DataSet ds = Session["ds"] as DataSet; DataTable dt = ds.Tables[0]; DataRow[] rows = dt.Select("CityName LIKE '" + txtSearch.Text + "%'"); gridCities.DataSource = rows; gridCities.DataBind();

Answer: BExplanation/Reference:

QUESTION 19You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication consumes a Microsoft Windows Communication Foundation (WCF) service.The WCF service exposes the following method.[WebInvoke] string UpdateCustomerDetails(string custID); The application hosts the WCF service by using the following code segment.WebServiceHost host = new WebServiceHost(typeof(CService), new Uri("http://win/")); ServiceEndpoint ep = host.AddServiceEndpoint(typeof(ICService), new WebHttpBinding(), ""); You need to invoke the UpdateCustomerDetails method.Which code segment should you use?

A. WebChannelFactory<ICService> wcf = new WebChannelFactory<ICService>(new Uri("http: //win")) ;ICService channel = wcf.CreateChannel(); string s = channel.UpdateCustomerDetails("CustID12");

B. WebChannelFactory<ICService> wcf = new WebChannelFactory<ICService>(new Uri("http://win/UpdateCustomerDetails"));ICService channel = wcf.CreateChannel(); string s = channel.UpdateCustomerDetails("CustID12");

C. ChannelFactory<ICService> cf = new ChannelFactory<ICService>(new WebHttpBinding(), "http: //win/UpdateCustomerDetails") ;ICService channel = cf.CreateChannel(); string s = channel.UpdateCustomerDetails("CustID12");

D. ChannelFactory<ICService> cf = new ChannelFactory<ICService>(new BasicHttpBinding(), "http: //win ");cf.Endpoint.Behaviors.Add(new WebHttpBehavior()); ICService channel = cf.CreateChannel(); string s = channel.UpdateCustomerDetails("CustID12");

Answer: AExplanation/Reference:

QUESTION 20You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Microsoft Windows Communication Foundation (WCF) service that exposes the following

Page 15: 70562 Questions

[email protected] (IT Chanakya)

service contract. (Line numbers are included for reference only.) 01 [ServiceContract] 02 public interface IBlogService 03 { 04 [OperationContract] 05 [WebGet(ResponseFormat=WebMessageFormat.Xml)] 06 Rss20FeedFormatter GetBlog(); 07 } You configure the WCF service to use the WebHttpBinding class, and to be exposed at the following URL:http://www.contoso.com/BlogService You need to store the result of the GetBlog operation in an XmlDocument variable named xmlBlog in a Webform.Which code segment should you use?

A. string url = @"http: //www.contoso.com/BlogService/GetBlog"; XmlReader blogReader = XmlReader.Create(url); xmlBlog.Load(blogReader);

B. string url = @"http: //www.contoso.com/BlogService"; XmlReader blogReader = XmlReader.Create(url); xmlBlog.Load(blogReader);

C. Uri blogUri = new Uri(@"http: //www.contoso.com/BlogService"); ChannelFactory<IBlogService> blogFactory = new ChannelFactory<IBlogService>(blogUri); IBlogService blogSrv = blogFactory.CreateChannel(); Rss20FeedFormatter feed = blogSrv.GetBlog(); xmlBlog.LoadXml(feed.ToString());

D. Uri blogUri = new Uri(@"http: //www.contoso.com/BlogService/GetBlog"); ChannelFactory<IBlogService> blogFactory = new ChannelFactory<IBlogService>(blogUri); IBlogService blogSrv = blogFactory.CreateChannel(); Rss20FeedFormatter feed = blogSrv.GetBlog(); xmlBlog.LoadXml(feed.Feed.ToString());

Answer: AExplanation/Reference:

QUESTION 21You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You plan to add a custom parameter in the SqlDataSource control.You write the following code fragment.<asp:SqlDataSource ID="SqlDataSource1" runat="server" InsertCommand="INSERT INTO [Employee]([Field1], [Field2], [PostedDate]) VALUES (@Field1, @Field2, @PostedDate)"> <InsertParameters> <asp:Parameter Name="Field1" /> <asp:Parameter Name="Field2" /> <custom:DayParameter?Name="PostedDate" /> </InsertParameters> </asp:SqlDataSource> You write the following code segment to create a custom parameter class.public class DayParameter : Parameter { }You need to ensure that the custom parameter returns the current date and time.Which code segment should you add to the DayParameter class?

A. protected DayParameter() : base("Value", TypeCode.DateTime, DateTime.Now.ToString()) {}

B. protected override void LoadViewState(object savedState) {((StateBag)savedState).Add("Value", DateTime.Now); }

Page 16: 70562 Questions

[email protected] (IT Chanakya)

C. protected override object Evaluate(HttpContext context, Control control) { return DateTime.Now; }D. protected override Parameter Clone() {

Parameter pm = new DayParameter(); pm.DefaultValue = DateTime.Now; return pm; }

Answer: CExplanation/Reference:

QUESTION 22You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication has an ASPX page named ErrorPage.aspx.You plan to manage the unhandled application exceptions.You need to perform the following tasks:Display the ErrorPage.aspx page Write the exceptioninformation in the Event log file.Which two actions should you perform? (Each correct answer presents part of the solution.Choose two.)

A. Add the following code fragment to the Web.config file.<customErrors mode="On" defaultRedirect="ErrorPage.aspx" />

B. Add the following code fragment to the Web.config file.<customErrors mode="Off" defaultRedirect="ErrorPage.aspx" />

C. Add the following code segment to the Global.asax file.void Application_Error(object sender, EventArgs e) { Exception exc = Server.GetLastError(); //Write Exception details to event log }

D. Add the following code segment to the ErrorPage.aspx file.void Page_Error(object sender, EventArgs e) { Exception exc = Server.GetLastError(); //Write Exception details to event log Server.ClearError(); }

Answer: ADExplanation/Reference:It is better to use Try/Catch blocks around any code that is subject to errors instead of relying on a global errorhandler.

An error handler that is defined in the Global.asax file will only catch errors that occur during processing ofrequests by the ASP.NET runtime. For example, it will catch the error if a user requests an .aspx file that doesnot occur in your application. However, it does not catch the error if a user requests a nonexistent .htm file.For non-ASP.NET errors, you can create a custom handler in Internet Information Services (IIS). The customhandler will also not be called for server-level errors.

You cannot directly output error information for requests from the Global.asax file; you must transfer control toanother page, typically a Web Forms page. When transferring control to another page, use Transfer method.This preserves the current context so that you can get error information from the GetLastError method. After handling an error, you must clear it by calling the ClearError method of the Server object(HttpServerUtility class).

QUESTION 23You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.

Page 17: 70562 Questions

[email protected] (IT Chanakya)

The application contains two Web pages named OrderDetails.aspx and OrderError.htm.If the application throws unhandled errors in the OrderDetails.aspx Web page, a stack trace is displayed toremote users.You need to ensure that the OrderError.htm Web page is displayed for unhandled errors only in theOrderDetails.aspx Web page.What should you do?

A. Set the Page attribute for the OrderDetails.aspx Web page in the following manner.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrderDetails.aspx.cs"Inherits="OrderDetails" %> Add the following section to the Web.config file.<customErrors mode="Off" defaultRedirect="OrderError.htm"> </customErrors>

B. Set the Page attribute for the OrderDetails.aspx Web page in the following manner.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrderDetails.aspx.cs"Inherits="OrderDetails" Debug="true" %> Add the following section to the Web.config file.<customErrors mode="On" defaultRedirect="OrderError.htm">

C. Set the Page attribute for the OrderDetails.aspx Web page in the following manner.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrderDetails.aspx.cs"Inherits="OrderDetails" ErrorPage="~/OrderError.htm" Debug="false" %> Add the following section to the Web.config file.<customErrors mode="On"> </customErrors>

D. Set the Page attribute for the OrderDetails.aspx Web page in the following manner.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrderDetails.aspx.cs"Inherits="OrderDetails" Debug="true" ErrorPage="~/OrderError.htm" %> Add the following section to the Web.config file.<customErrors mode="Off"> </customErrors>

Answer: CExplanation/Reference:Debug Indicates whether the page should be compiled with debug symbols. true if the page should be compiled withdebug symbols; otherwise, false. Because this setting affects performance, you should only set the attribute totrue during development. ErrorPage Defines a target URL for redirection if an unhandled page exception occurs.

QUESTION 24You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code fragment.

<asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="updateLabels" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" /> <asp:Label ID="Label2" runat="server" /> <asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" /> </ContentTemplate> </asp:UpdatePanel> <asp:Label id="Label3" runat="server" />

You need to ensure that when you click the btnSubmit Button control, each Label control value isasynchronously updatable.Which code segment should you use?

Page 18: 70562 Questions

[email protected] (IT Chanakya)

A. protected void btnSubmit_Click(object sender, EventArgs e) { Label1.Text = "Label1 updated value"; Label2.Text = "Label2 updated value"; Label3.Text = "Label3 updated value"; }

B. protected void btnSubmit_Click(object sender, EventArgs e) { Label1.Text = "Label1 updated value"; Label2.Text = "Label2 updated value"; ScriptManager1.RegisterDataItem(Label3, "Label3 updated value"); }

C. protected void btnSubmit_Click(object sender, EventArgs e) { ScriptManager1.RegisterDataItem(Label1, "Label1 updated value"); ScriptManager1.RegisterDataItem(Label2, "Label2 updated value"); Label3.Text = "Label3 updated value"; }

D. protected void btnSubmit_Click(object sender, EventArgs e) { Label1.Text = "Label1 updated value"; Label2.Text = "Label2 updated value"; ScriptManager1.RegisterAsyncPostBackControl(Label3); Label3.Text = "Label3 updated value"; }

Answer: BExplanation/Reference:Use the RegisterDataItem method to send data from the server to the client during asynchronous postbacks,regardless of whether the control receiving the data is inside an UpdatePanel control.

Use RegisterAsyncPostBackControl for Registers a control as a trigger for asynchronous postbacks.

QUESTION 25You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web form in the application by using the following code fragment. (Line numbers are includedfor reference only.) 01 <script runat="server"> 02 protected void Button_Handler(object sender, EventArgs e) 03 { 04 // some long-processing operation.05 } 06 </script> 07 <div> 08 <asp:ScriptManager ID="defaultScriptManager" 09 runat="server" /> 10 11 <asp:UpdatePanel ID="defaultPanel" 12 UpdateMode="Conditional" runat="server"> 13 <ContentTemplate> 14 <!-- more content here --> 15 <asp:Button ID="btnSubmit" runat="server" 16 Text="Submit" OnClick="Button_Handler" /> 17 </ContentTemplate> 18 </asp:UpdatePanel> 19 </div> You plan to create a client-side script code by using ASP.NET AJAX.You need to ensure that while a request is being processed, any subsequent Click events on the btnSubmitButton control are suppressed.Which code fragment should you insert at line 10?

Page 19: 70562 Questions

[email protected] (IT Chanakya)

A. <script type="text/javascript" language="javascript"> var rm = Sys.WebForms.PageRequestManager.getInstance(); rm.add_beginRequest(checkPostback); function checkPostback(sender, args) { if (rm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'btnSubmit') { rm.abortPostBack(); alert('A previous request is still in progress.'); }} </script>

B. <script type="text/javascript" language="javascript"> var rm = Sys.WebForms.PageRequestManager.getInstance(); rm.add_initializeRequest(checkPostback); function checkPostback(sender, args) { if (rm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'btnSubmit') { rm.abortPostBack(); alert('A previous request is still in progress.'); }} </script>

C. <script type="text/javascript" language="javascript"> var rm = Sys.WebForms.PageRequestManager.getInstance(); rm.add_initializeRequest(checkPostback); function checkPostback(sender, args) { if (rm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'btnSubmit') { args.set_cancel(true); alert('A previous request is still in progress.'); }} </script>

D. <script type="text/javascript" language="javascript"> var rm = Sys.WebForms.PageRequestManager.getInstance(); rm.add_beginRequest(checkPostback); function checkPostback(sender, args) { var request = args.get_request(); if (rm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'btnSubmit') { request.completed(new Sys.CancelEventArgs()); alert('A previous request is still in progress.'); }} </script>

Answer: CExplanation/Reference:rm.abortPostBack(); Cancel the postback that is currently runningargs.set_cancel(true); Cancel this postback

QUESTION 26You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code segment to create a JavaScript file named CalculatorScript.js.function divide(a, b) { if (b == 0) { var errorMsg = Messages.DivideByZero; alert(errorMsg); return null; } return a/b;

Page 20: 70562 Questions

[email protected] (IT Chanakya)

}

You embed the CalculatorScript.js file as a resource in a Class Library project. The namespace for this project is Calculator.Resources. The JavaScript function retrieves messages from a resource file named MessageResources.resx by using theJavaScript Messages object.You add an AJAX Web form in the ASP.NET application. You reference the Class Library in the application.You add an ASP.NET AJAX ScriptReference element to the AJAX Web form.You need to ensure that the JavaScript function can access the error messages that are defined in theresource file.Which code segment should you add in the AssemblyInfo.cs file?

A. [assembly: ScriptResource ("CalculatorScript", "MessageResources", "Messages")]B. [assembly: ScriptResource ("CalculatorScript.js", "MessageResources.resx", "Messages")]C. [assembly: ScriptResource ("Calculator.Resources.CalculatorScript.js", "Calculator.Resources.

MessageResources", "Messages")]D. [assembly: ScriptResource ("Calculator.Resources.CalculatorScript", "Calculator.Resources.

MessageResources.resx", "Messages")]

Answer: CExplanation/Reference:

QUESTION 27You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create an AJAX-enabled Web form by using the following code fragment.<asp:ScriptManager ID="scrMgr" runat="server" /> <asp:UpdatePanel runat="server" ID="updFirstPanel" UpdateMode="Conditional"> <ContentTemplate> <asp:TextBox runat="server" ID="txtInfo" /> <asp:Button runat="server" ID="btnSubmit" Text="Submit" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel runat="server" ID="updSecondPanel" UpdateMode="Conditional"> <ContentTemplate> ...</ContentTemplate> </asp:UpdatePanel> When the updFirstPanel UpdatePanel control is updated, a dynamic client script is registered.You write the following code segment in the code-behind file of the Web form. (Line numbers are included forreference only.) 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 if(IsPostBack) 04 { 05 string generatedScript = ScriptGenerator.GenerateScript(); 06 07 } 08 } You need to ensure that the client-script code is registered only when an asynchronous postback is issued onthe updFirstPanel UpdatePanel control.Which code segment should you insert at line 06?

A. ClientScript.RegisterClientScriptBlock(typeof(TextBox), "txtInfo_Script", generatedScript);B. ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "txtInfo_Script", generatedScript, false);C. ClientScript.RegisterClientScriptBlock(typeof(Page), "txtInfo_Script", generatedScript);

Page 21: 70562 Questions

[email protected] (IT Chanakya)

D. ScriptManager.RegisterClientScriptBlock(txtInfo, typeof(TextBox), "txtInfo_Script", generatedScript, false);

Answer: DExplanation/Reference:

QUESTION 28You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application contains the following code segment.public class CapabilityEvaluator { public static bool ChkScreenSize( System.Web.Mobile.MobileCapabilities cap, String arg) { int screenSize = cap.ScreenCharactersWidth * cap.ScreenCharactersHeight; return screenSize < int.Parse(arg); }

}

You add the following device filter element to the Web.config file.<filter name="FltrScreenSize" type="MyWebApp.CapabilityEvaluator,MyWebApp" method="ChkScreenSize" /> You need to write a code segment to verify whether the size of the device display is less than 80 characters.Which code segment should you use?

A. MobileCapabilities currentMobile; currentMobile = Request.Browser as MobileCapabilities; if(currentMobile.HasCapability("FltrScreenSize","80")) {}

B. MobileCapabilities currentMobile; currentMobile = Request.Browser as MobileCapabilities; if(currentMobile.HasCapability( "FltrScreenSize","").ToString()=="80") {}

C. MobileCapabilities currentMobile; currentMobile = Request.Browser as MobileCapabilities; if (currentMobile.HasCapability( "CapabilityEvaluator.ChkScreenSize", "80")) {}

D. MobileCapabilities currentMobile; currentMobile = Request.Browser as MobileCapabilities; if (currentMobile.HasCapability( "CapabilityEvaluator.ChkScreenSize", "").ToString()=="80") {}

Answer: AExplanation/Reference:

QUESTION 29You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication has a mobile Web form that contains the following ObjectList control.<mobile:ObjectList ID="ObjectListCtrl" OnItemCommand="ObjectListCtrl_ItemCommand" Runat="server"> <Command Name="CmdDisplayDetails" Text="Details" /> <Command Name="CmdRemove" Text="Remove" /> </mobile:ObjectList> You create an event handler named ObjectListCtrl_ItemCommand.You need to ensure that the ObjectListCtrl_ItemCommand handler detects the selection of theCmdDisplayDetails item.Which code segment should you write?

Page 22: 70562 Questions

[email protected] (IT Chanakya)

A. public void ObjectListCtrl_ItemCommand( object sender, ObjectListCommandEventArgs e) {if (e.CommandName == "CmdDisplayDetails") {} }

B. public void ObjectListCtrl_ItemCommand( object sender, ObjectListCommandEventArgs e) {if (e.CommandArgument.ToString() == "CmdDisplayDetails") {} }

C. public void ObjectListCtrl_ItemCommand( object sender, ObjectListCommandEventArgs e) {ObjectListCommand cmd = sender as ObjectListCommand; if (cmd.Name == "CmdDisplayDetails") {} }

D. public void ObjectListCtrl_ItemCommand( object sender, ObjectListCommandEventArgs e) {ObjectListCommand cmd = e.CommandSource as ObjectListCommand; if (cmd.Name == "CmdDisplayDetails") {} }

Answer: AExplanation/Reference:

QUESTION 30You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.All the content pages in the application use a single master page. The master page uses a static navigationmenu to browse the site.You need to ensure that the content pages can optionally replace the static navigation menu with their ownmenu controls.What should you do?

A. Add the following code fragment to the master page <asp:PlaceHolder ID="MenuPlaceHolder"runat="server"> <div id="menu"> <!-- Menu code here --> </div> </asp:PlaceHolder>Add the following code segment to the Page_Load event of the content page PlaceHolder placeHolder = Page.Master.FindControl("MenuPlaceHolder") as PlaceHolder; Menu menuControl = new Menu(); placeHolder.Controls.Add(menuControl);

B. Add the following code fragment to the master page <asp:ContentPlaceHolder ID="MenuPlaceHolder"runat="server"> <!-- Menu code here --> </asp:ContentPlaceHolder>Add the following code fragment to the content page <asp:ContentContentPlaceHolderID="MenuPlaceHolder"> <asp:menu ID="menuControl" runat="server"> </ asp: menu</asp:Content>

C. Add the following code fragment to the master page <asp:ContentPlaceHolder ID="MenuPlaceHolder"runat="server"> <!-- Menu code here --> </asp:ContentPlaceHolder>Add the following code segment to the Page_Load event of the content page ContentPlaceHolder placeHolder = Page.Master.FindControl("MenuPlaceHolder") as ContentPlaceHolder; Menu menuControl = new Menu(); placeHolder.Controls.Add(menuControl);

D. Add the following code fragment to the master page <asp:PlaceHolder ID="MenuPlaceHolder"runat="server"> <!-- Menu code here --> </asp:ContentPlaceHolder>Add the following code fragment to the content page <asp:Content PlaceHolderID="MenuPlaceHolder"><asp:menu ID="menuControl" runat="server"> </ asp: menu </asp:Content>

Answer: BExplanation/Reference:

QUESTION 31

Page 23: 70562 Questions

[email protected] (IT Chanakya)

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application allows users to post comments to a page that can be viewed by other users.You add a SqlDataSource control named SqlDS1. You write the following code segment. (Line numbers are included for reference only.) 01 private void SaveComment() 02 { 03 string ipaddr; 04 05 SqlDS1.InsertParameters["IPAddress"].DefaultValue = ipaddr; 06 ...07 SqlDS1.Insert(); 08 } You need to ensure that the IP Address of each user who posts a comment is captured along with the user'scomment.Which code segment should you insert at line 04?

A. ipaddr = Server["REMOTE_ADDR"].ToString();B. ipaddr = Session["REMOTE_ADDR"].ToString();C. ipaddr = Application["REMOTE_ADDR"].ToString();D. ipaddr = Request.ServerVariables["REMOTE_ADDR"].ToString();

Answer: DExplanation/Reference:

QUESTION 32You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web page named Default.aspx in the root of the application. You add an ImageResources.resxresource file in the App_GlobalResources folder. The ImageResources.resx file contains a localized resourcenamed LogoImageUrl.You need to retrieve the value of LogoImageUrl.Which code segment should you use?

A. string logoImageUrl = (string)GetLocalResource("LogoImageUrl");B. string logoImageUrl = (string)GetGlobalResource("Default", "LogoImageUrl");C. string logoImageUrl = (string)GetGlobalResource("ImageResources", "LogoImageUrl");D. string logoImageUrl = (string)GetLocalResource("ImageResources.LogoImageUrl");

Answer: CExplanation/Reference:

QUESTION 33You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a custom Web user control named SharedControl. The control will be compiled as a library.You write the following code segment for the SharedControl control. (Line numbers are included for referenceonly.) 01 protected override void OnInit(EventArgs e) 02 { 03 base.OnInit(e); 04 05 } All the master pages in the ASP.NET application contain the following directive.<%@ Master Language="C#" EnableViewState="false" %>

Page 24: 70562 Questions

[email protected] (IT Chanakya)

You need to ensure that the state of the SharedControl control can persist on the pages that reference amaster page.Which code segment should you insert at line 04?

A. Page.RegisterRequiresPostBack(this);B. Page.RegisterRequiresControlState(this);C. Page.UnregisterRequiresControlState(this);D. Page.RegisterStartupScript("SharedControl","server");

Answer: BExplanation/Reference:

QUESTION 34You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web page that has a GridView control named GridView1. The GridView1 control displays thedata from a database named Region and a table named Location.You write the following code segment to populate the GridView1 control. (Line numbers are included forreference only.) 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 string connstr; 04 05 SqlDependency.Start(connstr); 06 using (SqlConnection connection = 07 new SqlConnection(connstr)) 08 { 09 SqlCommand sqlcmd = new SqlCommand(); 10 DateTime expires = DateTime.Now.AddMinutes(30); 11 SqlCacheDependency dependency = new 12 SqlCacheDependency("Region", "Location"); 13 Response.Cache.SetExpires(expires); 14 Response.Cache.SetValidUntilExpires(true); 15 Response.AddCacheDependency(dependency); 16 17 sqlcmd.Connection = connection; 18 GridView1.DataSource = sqlcmd.ExecuteReader(); 19 GridView1.DataBind(); 20 } 21 } You need to ensure that the proxy servers can cache the content of the GridView1 control.Which code segment should you insert at line 16?

A. Response.Cache.SetCacheability(HttpCacheability.Private);B. Response.Cache.SetCacheability(HttpCacheability.Public);C. Response.Cache.SetCacheability(HttpCacheability.Server);D. Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);

Answer: BExplanation/Reference:HttpCacheability

NoCache Sets the Cache-Control: no-cache header. Without a field name, the directive applies to the entirerequest and a shared (proxy server) cache must force a successful revalidation with the origin Web serverbefore satisfying the request. With a field name, the directive applies only to the named field; the rest of the

Page 25: 70562 Questions

[email protected] (IT Chanakya)

response may be supplied from a shared cache. Private Default value. Sets Cache-Control: private to specify that the response is cacheable only on the clientand not by shared (proxy server) caches. Server Specifies that the response is cached only at the origin server. Similar to the NoCache option. Clientsreceive a Cache-Control: no-cache directive but the document is cached on the origin server. Equivalent toServerAndNoCache. ServerAndNoCache Applies the settings of both Server and NoCache to indicate that the content is cachedat the server but all others are explicitly denied the ability to cache the response. Public Sets Cache-Control: public to specify that the response is cacheable by clients and shared (proxy)caches. ServerAndPrivate Indicates that the response is cached at the server and at the client but nowhere else.Proxy servers are not allowed to cache the response.

QUESTION 35You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a page that contains the following control.<asp:Calendar EnableViewState="false"ID="calBegin" runat="server" /> You write the following code segment in the code-behind file for the page.void LoadDate(object sender, EventArgs e) { if (IsPostBack) { calBegin.SelectedDate = (DateTime)ViewState["date"]; }} void SaveDate(object sender, EventArgs e) { ViewState["date"] = calBegin.SelectedDate; }You need to ensure that the calBegin Calendar control maintains the selected date.Which code segment should you insert in the constructor of the page?

A. this.Load += new EventHandler(LoadDate); this.Unload += new EventHandler(SaveDate);B. this.Init += new EventHandler(LoadDate); this.Unload += new EventHandler(SaveDate);C. this.Init += new EventHandler(LoadDate); this.PreRender += new EventHandler(SaveDate);D. this.Load += new EventHandler(LoadDate); this.PreRender += new EventHandler(SaveDate);

Answer: DExplanation/Reference:

QUESTION 36You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a page that contains the following code fragment.<asp:ListBox ID="lstLanguages"AutoPostBack="true" runat="server" />

You write the following code segment in the code-behind file for the page. void BindData(object sender, EventArgs e) { lstLanguages.DataSource = CultureInfo.GetCultures(CultureTypes.AllCultures); lstLanguages.DataTextField = "EnglishName"; lstLanguages.DataBind(); }

You need to ensure that the lstLanguages ListBox control maintains the selection of the user during postback.Which line of code should you insert in the constructor of the page?

A. this.Init += new EventHandler(BindData);B. this.PreRender += new EventHandler(BindData);

Page 26: 70562 Questions

[email protected] (IT Chanakya)

C. lstLanguages.PreRender += new EventHandler(BindData);D. lstLanguages.SelectedIndexChanged += new EventHandler(BindData);

Answer: AExplanation/Reference:

QUESTION 37You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication runs on Microsoft IIS 6.0.You create a page named oldPage.aspx.You need to ensure that the following requirements are met when a user attempts to access the page:The browser diplays the URL of the oldPage.aspx page.The browser displays the page named newPage.aspx Which code segment should you use?

A. Server.Transfer("newPage.aspx");B. Response.Redirect("newPage.aspx");C. if (Request.Url.UserEscaped) { Server.TransferRequest("newPage.aspx"); }

else { Response.Redirect("newPage.aspx", true); }D. if (Request.Url.UserEscaped) { Response.RedirectLocation = "oldPage.aspx"; Response.Redirect

("newPage.aspx", true); }else { Response.Redirect("newPage.aspx"); }

Answer: A

QUESTION 38You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web page named enterName.aspx. The Web page contains a TextBox control named txtName.The Web page cross posts to a page named displayName.aspx that contains a Label control named lblName.You need to ensure that the lblName Label control displays the text that was entered in the txtName TextBoxcontrol.Which code segment should you use?

A. lblName.Text = Request.QueryString["txtName"];B. TextBox txtName = FindControl("txtName") as TextBox; lblName.Text = txtName.Text;C. TextBox txtName = Parent.FindControl("txtName") as TextBox; lblName.Text = txtName.Text;D. TextBox txtName = PreviousPage.FindControl("txtName") as TextBox; lblName.Text = txtName.Text;

Answer: D

QUESTION 39You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code segment to create a class named MultimediaDownloader that implements theIHttpHandler interface.namespace Contoso.Web.UI {public class MultimediaDownloader : IHttpHandler {...} }The MultimediaDownloader class performs the following tasks:It returns the content of the multimedia files from the Web server It processes requests for the files that havethe .media file extension The .media file extension is mapped to the aspnet_isapi.dll file in Microsoft IIS 6.0.You need to configure the MultimediaDownloader class in the Web.config file of the application.

Page 27: 70562 Questions

[email protected] (IT Chanakya)

Which code fragment should you use?

A. <httpHandlers> <add verb="*.media" path="*" validate="false" type="Contoso.Web.UI.MultimediaDownloader" /> </httpHandlers>

B. <httpHandlers> <add verb="HEAD" path="*.media" validate="true" type="Contoso.Web.UI.MultimediaDownloader" /> </httpHandlers>

C. <httpHandlers> <add verb="*" path="*.media" validate="false" type="Contoso.Web.UI.MultimediaDownloader" /> </httpHandlers>

D. <httpHandlers> <add verb="GET,POST" path="*" validate="true" type="Contoso.Web.UI.MultimediaDownloader" /> </httpHandlers>

Answer: C

QUESTION 40You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a class that implements the IHttpHandler interface. You implement the ProcessRequest method byusing the following code segment. (Line numbers are included for reference only.) 01 public void ProcessRequest(HttpContext ctx) { 02 03 } You need to ensure that the image named Alert.jpg is displayed in the browser when the handler is requested.Which code segment should you insert at line 02?

A. StreamReader sr = new StreamReader(File.OpenRead(ctx.Server.MapPath("Alert.jpg"))); ctx.Response.Pics(sr.ReadToEnd()); sr.Close();

B. StreamReader sr = new StreamReader(File.OpenRead(ctx.Server.MapPath("Alert.jpg"))); ctx.Response.Pics("image/jpg"); ctx.Response.TransmitFile(sr.ReadToEnd()); sr.Close();

C. ctx.Response.ContentType = "image/jpg"; FileStream fs = File.OpenRead(ctx.Server.MapPath("Alert.jpg")); int b; while ((b = fs.ReadByte()) != -1) { ctx.Response.OutputStream.WriteByte((byte)b); }fs.Close();

D. ctx.Response.TransmitFile("image/jpg"); FileStream fs = File.OpenRead(ctx.Server.MapPath("Alert.jpg")); int b; while ((b = fs.ReadByte()) != -1) { ctx.Response.OutputStream.WriteByte((byte)b); }fs.Close();

Answer: CExplanation/Reference:

QUESTION 41You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.The computer that hosts the ASP.NET Web application contains a local instance of Microsoft SQL Server2005. The instance uses Windows Authentication. You plan to configure the membership providers and therole management providers.

Page 28: 70562 Questions

[email protected] (IT Chanakya)

You need to install the database elements for both the providers on the local computer.What should you do?

A. Run the sqlcmd.exe -S localhost E command from the command line.B. Run the aspnet_regiis.exe -s localhost command from the command line.C. Run the sqlmetal.exe /server:localhost command from the command line.D. Run the aspnet_regsql.exe -E -S localhost -A mr command from the command line.

Answer: D

QUESTION 42You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.You use Windows Authentication for the application. You set up NTFS file system permissions for the Salesgroup to access a particular file. You discover that all the users are able to access the file.You need to ensure that only the Sales group users can access the file.What additional step should you perform?

A. Remove the rights from the ASP.NET user to the file.B. Remove the rights from the application pool identity to the file.C. Add the <identity impersonate="true"/> section to the Web.config file.D. Add the <authentication mode="[None]"> section to the Web.config file.

Answer: C

QUESTION 43You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.You plan to set up authentication for the Web application. The application must support users from untrusteddomains.You need to ensure that anonymous users cannot access the application.Which code fragment should you add to the Web.config file?

A. <system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx" /> </authentication><authorization> <deny users="?" /> </authorization> </system.web>

B. <system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx" /> </authentication><authorization> <deny users="*" /> </authorization> </system.web>

C. <system.web> <authentication mode="Windows"> </authentication> <authorization> <deny users="?" /></authorization> </system.web>

D. <system.web> <authentication mode="Windows"> </authentication> <authorization> <deny users="*" /> </authorization> </system.web>

Answer: A

QUESTION 44You are maintaining a Microsoft ASP.NET Web Application that was created by using the Microsoft .NETFramework version 3.5.You obtain the latest version of the project from the source control repository. You discover that an assemblyreference is missing when you attempt to compile the project on your computer.You need to compile the project on your computer.What should you do?

A. Add a reference path in the property pages of the project to the location of the missing assembly.

Page 29: 70562 Questions

[email protected] (IT Chanakya)

B. Add a working directory in the property pages of the project to the location of the missing assembly.C. Change the output path in the property pages of the project to the location of the missing assembly.D. Delete the assembly reference. Add a reference to the missing assembly by browsing for it on your

computer.

Answer: A

QUESTION 45You have a Microsoft ASP.NET Framework version 1.0 application. The application does not use any featuresthat are deprecated in the Microsoft .NET Framework version 3.5. The application runs on Microsoft IIS 6.0.You need to configure the application to use the ASP.NET Framework version 3.5 without recompiling theapplication.What should you do?

A. Edit the ASP.NET runtime version in IIS 6.0.B. Edit the System.Web section handler version number in the machine.config file.C. Add the requiredRuntime configuration element to the Web.config file and set the version attribute to v3.5.D. Add the supportedRuntime configuration element in the Web.config file and set the version attribute to

v3.5.

Answer: A

QUESTION 46You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.The application uses ASP.NET AJAX, and you plan to deploy it in a Web farm environment.You need to configure SessionState for the application.Which code fragment should you use?

A. <sessionState mode="InProc"cookieless="UseCookies"/>B. <sessionState mode="InProc"cookieless="UseDeviceProfile"/>C. <sessionState mode="SQLServer"cookieless="UseCookies" sqlConnectionString="Integrated

Security=SSPI;data source=MySqlServer;"/>D. <sessionState mode="SQLServer"cookieless="UseUri" sqlConnectionString="Integrated Security=SSPI;

data source=MySqlServer;"/>

Answer: CExplanation/Reference:When you configure an AJAX-enabled ASP.NET Web site, use only the default value of UseCookies for thecookieless attribute. Settings that use cookies encoded in the URL are not supported by the ASP.NET AJAXclient script libraries.

QUESTION 47You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.You deploy the application on a Microsoft IIS 6.0 Web server. The server runs on a worker process isolationmode, and it hosts the .NET Framework version 1.1 Web applications.When you attempt to browse the application, the following error message is received:"It is not possible to run different versions of ASP.NET in the same IIS process. Please use the IISAdministration Tool to reconfigure your server to run the application in a separate process." You need toensure that the following requirements are met:All the applications run on the server All the applications remain in process isolation mode All theapplications do not change their configuration.

Page 30: 70562 Questions

[email protected] (IT Chanakya)

Which two actions should you perform? (Each correct answer presents part of the solution.Choose two.)

A. Create a new application pool and add the new application to the pool.B. Configure the IIS 6.0 to run the WWW service in the IIS 5.0 isolation mode.C. Configure the new application to use the .NET Framework version 2.0 in the IIS 6.0 Manager.D. Set autoConfig="false" on the <processModel> property in the machine.config file.E. Disable the Recycle worker processes option in the Application Pool Properties dialog box.

Answer: AC

QUESTION 48You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application has a Web form file named MovieReviews.aspx.The MovieReviews.aspx file connects to a LinqDataSource DataSource named LinqDataSource1 that has aprimary key named MovieID.The application has a DetailsView control named DetailsView1.The MovieReviews.aspx file contains the following code fragment. (Line numbers are included for referenceonly.) 01 <asp:DetailsView ID="DetailsView1" runat="server" 02 DataSourceID="LinqDataSource1" 03 04 />05 <Fields> 06 <asp:BoundField DataField="MovieID" HeaderText="MovieID" 07 InsertVisible="False" 08 ReadOnly="True" SortExpression="MovieID" /> 09 <asp:BoundField DataField="Title" HeaderText="Title" 10 SortExpression="Title" /> 11 <asp:BoundField DataField="Theater" HeaderText="Theater" 12 SortExpression="Theater" /> 13 <asp:CommandField ShowDeleteButton="false" 14 ShowEditButton="True" ShowInsertButton="True" /> 15 </Fields> 16 </asp:DetailsView> You need to ensure that the users can insert and update content in the DetailsView1 control.You also need to prevent duplication of the link button controls for the Edit and New operations.Which code segment should you insert at line 03?

A. AllowPaging="false" AutoGenerateRows="false"B. AllowPaging="true" AutoGenerateRows="false" DataKeyNames="MovieID"C. AllowPaging="true" AutoGenerateDeleteButton="false" AutoGenerateEditButton="true"

AutoGenerateInsertButton="true" AutoGenerateRows="false"D. AllowPaging="false" AutoGenerateDeleteButton="false" AutoGenerateEditButton="true"

AutoGenerateInsertButton="true" AutoGenerateRows="false" DataKeyNames="MovieID"

Answer: BExplanation/Reference:

QUESTION 49You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a custom-templated server control.

Page 31: 70562 Questions

[email protected] (IT Chanakya)

You need to ensure that the child controls of the server control are uniquely identified within the controlhierarchy of the page.Which interface should you implement?

A. the ITemplatable interfaceB. the INamingContainer interfaceC. the IRequiresSessionState interfaceD. the IPostBackDataHandler interface

Answer: B

QUESTION 50You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code fragment. (Line numbers are included for reference only.) 01 <asp:RequiredFieldValidator 02 ID="rfValidator1" runat="server" 03 Display="Dynamic" ControlToValidate="TextBox1" 04 05 > 06 07 </asp:RequiredFieldValidator> 08 09 <asp:ValidationSummary DisplayMode="List" 10 ID="ValidationSummary1" runat="server" /> You need to ensure that the error message displayed in the validation control is also displayed in thevalidation summary list.What should you do?

A. Add the following code segment to line 06.Required text in TextBox1

B. Add the following code segment to line 04.Text="Required text in TextBox1"

C. Add the following code segment to line 04.ErrorMessage="Required text in TextBox1"

D. Add the following code segment to line 04.Text="Required text in TextBox1" ErrorMessage="ValidationSummary1"

Answer: CExplanation/Reference:

QUESTION 51You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You plan to submit text that contains HTML code to a page in the application.You need to ensure that the HTML code can be submitted successfully without affecting other applicationsthat run on the Web server.What should you do?

A. Add the following attribute to the @Page directive.EnableEventValidation="true"

B. Add the following attribute to the @Page directive.ValidateRequest="true"

Page 32: 70562 Questions

[email protected] (IT Chanakya)

C. Set the following value in the Web.config file.<system.web> <pages validateRequest="false"/> </system.web>

D. Set the following value in the Machine.config file.<system.web> <pages validateRequest="false"/> </system.web>

Answer: CExplanation/Reference:The request validation feature of ASP.NET 1.1 prevents the server from accepting content that containsunencoded HTML. You can disable request validation by setting the validateRequest attribute to false in the@ Page directive or in the configuration section.

Disable Request Validation on a PageTo disable request validation on a page, you must set the validateRequest attribute of the @ Page directiveto false: <%@ Page validateRequest="false" %>Note When request validation is disabled, content is submitted to a page. The page developer must makesure that the content is correctly encoded or is correctly processed.

Disable Request Validation for Your ApplicationTo disable request validation for your application, you must modify or create a Web.config file for yourapplication and then set the validateRequest attribute of the <PAGES /> section to false:

QUESTION 52You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication consumes an ASMX Web service.The Web service is hosted at the following URL.http://www.contoso.com/TemperatureService/Convert.asmx You need to ensure that the client computers cancommunicate with the service as part of the <system.serviceModel> configuration.Which code fragment should you use?

A. <client> <endpoint address="http: //www.contoso.com/TemperatureService/Convert.asmx"binding="wsHttpBinding" / </client>

B. <client> <endpoint address="http: //www.contoso.com/TemperatureService/Convert.asmx"binding="basicHttpBinding" / </client>

C. <client> <endpoint address="http: //www.contoso.com/TemperatureService/Convert.asmx"binding="ws2007HttpBinding" / </client>

D. <client> <endpoint address="http: //www.contoso.com/TemperatureService/Convert.asmx"binding="wsDualHttpBinding" / </client>

Answer: B

QUESTION 53You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a file named movies.xml that contains the following code fragment.<Movies> <Movie ID="1" Name="Movie1" Year="2006"> <Desc Value="Movie desc"/> </Movie> <Movie ID="2" Name="Movie2" Year="2007"> <Desc Value="Movie desc"/> </Movie> <Movie ID="3" Name="Movie3" Year="2008"> <Desc Value="Movie desc"/> </Movie>

Page 33: 70562 Questions

[email protected] (IT Chanakya)

</Movies> You add a Web form to the application.You write the following code segment in the Web form. (Line numbers are included for reference only.) 01 <form runat="server">02 <asp:xmldatasource 03 id="XmlDataSource1" 04 runat="server" 05 datafile="movies.xml" /> 06 07 </form> You need to implement the XmlDataSource control to display the XML data in a TreeView control.Which code segment should you insert at line 06?

A. <asp:TreeView ID="TreeView1" runat="server"DataSourceID="XmlDataSource1"> <DataBindings> <asp:TreeNodeBinding DataMember="Movie" Text="Name" /> </DataBindings> </asp:TreeView>

B. <asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1"> <DataBindings> <asp:TreeNodeBinding DataMember="Movies" Text="Desc" /> </DataBindings> </asp:TreeView>

C. <asp:TreeView ID="TreeView1" runat="server" DataSourceID="MovDataSource1"> <DataBindings> <asp:TreeNodeBinding DataMember="Movie" Text="Name" /> </DataBindings> </asp:TreeView>

D. <asp:TreeView ID="TreeView1" runat="server" DataSourceID="MovDataSource1"> <DataBindings> <asp:TreeNodeBinding DataMember="Movies" Text="Desc" /> </DataBindings> </asp:TreeView>

Answer: AExplanation/Reference:

QUESTION 54You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a FormView control to access the results of a query. The query contains the following fields:EmployeID FirstNam LastNam The user must be able to view and update the FirstName field.You need to define the control definition for the FirstName field in the FormView control.Which code fragment should you use?

A. <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server" Text="<%# Bind("FirstName") %>" />B. <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server" Text="<%# Eval("FirstName") %>" />C. <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server" Text='<%# Bind("FirstName") %>' />D. <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server" Text='<%# Eval("FirstName") %>' />

Answer: C

Page 34: 70562 Questions

[email protected] (IT Chanakya)

Explanation/Reference:

QUESTION 55You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application contains a DataSourceControl named CategoriesDataSource that is bound to a Microsoft SQLServer 2005 table. The CategoryName column is the primary key of the table.You write the following code fragment in a FormView control. (Line numbers are included for reference only.) 01 <tr> 02 <td align="right"><b>Category:</b></td> 03 <td><asp:DropDownList ID="InsertCategoryDropDownList" 04 05 DataSourceID="CategoriesDataSource" 06 DataTextField="CategoryName" 07 DataValueField="CategoryID" 08 RunAt="Server" /> 09 </td> 10 </tr> You need to ensure that the changes made to the CategoryID field can be written to the database.Which code fragment should you insert at line 04?

A. SelectedValue='<%# Eval("CategoryID") %>'B. SelectedValue='<%# Bind("CategoryID") %>'C. SelectedValue='<%# Eval("CategoryName") %>'D. SelectedValue='<%# Bind("CategoryName") %>'

Answer: BExplanation/Reference:

QUESTION 56You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web page to display photos and captions. The caption of each photo in the database can bemodified by using the application.You write the following code fragment.<asp:FormView DataSourceID="ObjectDataSource1" DataKeyNames="PhotoID" runat="server"> <EditItemTemplate> <asp:TextBox Text='<%# Bind("Caption") %>' runat="server"/> <asp:Button Text="Update" CommandName="Update" runat="server"/> <asp:Button Text="Cancel" CommandName="Cancel" runat="server"/></EditItemTemplate><ItemTemplate> <asp:Label Text='<%# Eval("Caption") %>' runat="server" /> <asp:Button Text="Edit" CommandName="Edit" runat="server"/> </ItemTemplate> </asp:FormView> When you access the Web page, the application throws an error.You need to ensure that the application successfully updates each caption and stores it in the database.What should you do?

A. Add the ID attribute to the Label control.B. Add the ID attribute to the TextBox control.C. Use the Bind function for the Label control instead of the Eval function.D. Use the Eval function for the TextBox control instead of the Bind function.

Page 35: 70562 Questions

[email protected] (IT Chanakya)

Answer: BExplanation/Reference:

QUESTION 57You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The application contains two HTML pages named ErrorPage.htm and PageNotFound.htm.You need to ensure that the following requirements are met:When the userrequests a page that does not exist, the PageNotFound.htm page is displayed.When any other error occurs, the ErrorPage.htm page is displayed.Which section should you add to the Web.config file?

A. <customErrors mode="Off" defaultRedirect="ErrorPage.htm"> <error statusCode="404"redirect="PageNotFound.htm"/> </customErrors>

B. <customErrors mode="On" defaultRedirect="ErrorPage.htm"> <error statusCode="404"redirect="PageNotFound.htm"/> </customErrors>

C. <customErrors mode="Off"> <error statusCode="400" redirect="ErrorPage.htm"/> <errorstatusCode="404" redirect="PageNotFound.htm"/> </customErrors>

D. <customErrors mode="On"> <error statusCode="400" redirect="ErrorPage.htm"/> <errorstatusCode="404" redirect="PageNotFound.htm"/> </customErrors>

Answer: BExplanation/Reference:

QUESTION 58You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You plan to deploy the application to a test server.You need to ensure that during the initial request to the application, the code-behind files for the Web pagesare compiled. You also need to optimize the performance of the application.Which code fragment should you add to the Web.config file?

A. <compilation debug="true">B. <compilation debug="false">C. <compilation debug="true" batch="true">D. <compilation debug="false" batch="false">

Answer: BExplanation/Reference:ensure that during the initial request to the application, the code-behind files for the Web pages are compiledis Batch="True" (Batch default=true)

You also need to optimize the performance of the application.is Debug="false" (Debug default=false)

QUESTION 59You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You host the application on a server named ContosoTest that runs Microsoft IIS 6.0. You set up remotedebugging on the ContosoTest server.You need to debug the application remotely from another computer named ContosoDev.What should you do?

Page 36: 70562 Questions

[email protected] (IT Chanakya)

A. Attach Microsoft Visual Studio.NET to the w3wp.exe process.B. Attach Microsoft Visual Studio.NET to the inetinfo.exe process.C. Attach Microsoft Visual Studio.NET to the Msvsmon.exe process.D. Attach Microsoft Visual Studio.NET to the WebDev.WebServer.exe process.

Answer: A

QUESTION 60You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application resides on a server named ContosoTest that runs Microsoft IIS 5.0.You use a computer named ContosoDev to log on to the Contoso.com domain with an account namedContosoUser.The ContosoTest and ContosoDev servers are members of the Contoso.com domain.You need to set up the appropriate permission for remote debugging.What should you do?

A. Set the Remote Debugging Monitor to use Windows Authentication.B. Add the ContosoUser account to the domain Administrators group.C. Add the ContosoUser account to the local Administrators group on the ContosoTest server.D. Change the ASP.NET worker process on the ContosoTest server to run as the local Administrator account.

Answer: C

QUESTION 61You create a Microsoft ASP.NET AJAX application by using the Microsoft .NET Framework version 3.5.You attach Microsoft Visual Studio 2008 debugger to the Microsoft Internet Explorer instance to debug theJavaScript code in the AJAX application.You need to ensure that the application displays the details of the client-side object on the debugger console.What should you do?

A. Use the Sys.Debug.fail method.B. Use the Sys.Debug.trace method.C. Use the Sys.Debug.assert method.D. Use the Sys.Debug.traceDump method.

Answer: DExplanation/Reference:displays the details of the client-side object on the debugger console.Object use Sys.Debug.traceDump method.

if Display Text use Sys.Debug.trace method.

QUESTION 62You create a Microsoft ASP.NET AJAX application by using the Microsoft .NET Framework version 3.5.A JavaScript code segment in the AJAX application does not exhibit the desired behavior.Microsoft Internet Explorer displays an error icon in the status bar but does not prompt you to debug the script.You need to configure the Internet Explorer to prompt you to debug the script.Which two actions should you perform? (Each correct answer presents part of the solution.Choose two.)

Page 37: 70562 Questions

[email protected] (IT Chanakya)

A. Clear the Disable Script Debugging (Other) check box.B. Clear the Disable Script Debugging (Internet Explorer) check box.C. Select the Show friendly HTTP error messages check box.D. Select the Enable third-party browser extensions check box.E. Select the Display a notification about every script error check box.

Answer: BE

QUESTION 63You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You plan to capture the timing and performance information of the application.You need to ensure that the information is accessible only when the user is logged on to the Web server andnot on individual Web pages.What should you add to the Web.config file?

A. <compilation debug="true" />B. <compilation debug="false" urlLinePragmas="true" />C. <trace enabled="true" pageOutput="false" localOnly="true" />D. <trace enabled="true" writeToDiagnosticsTrace="true" pageOutput="true" localOnly="true" />

Answer: CExplanation/Reference:is accessible only when the user is logged on to the Web serveris localOnly="true" (default=true)

not on individual Web pages.is pageOutput="false" (default=false)

QUESTION 64You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.When you access the application in a Web browser, you receive the following error message:"Service Unavailable".You need to access the application successfully.What should you do?

A. Start Microsoft IIS 6.0.B. Start the Application pool.C. Set the .NET Framework version.D. Add the Web.config file for the application.

Answer: B

QUESTION 65You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application is deployed on a Microsoft IIS 6.0 Web server by using the default ASP.NET version 2.0application pool and Windows Authentication.The application contains functionality to upload files to a location on a different server.Users receive an access denied error message when they attempt to submit a file.You need to modify the Web.config file to resolve the error.Which code fragment should you use?

Page 38: 70562 Questions

[email protected] (IT Chanakya)

A. <identity impersonate="true" />B. <anonymousIdentification enabled="true" />C. <roleManager enabled="true"defaultProvider="AspNetWindowsTokenRolePRovider" />D. <authorization> <allow users="*" /> </authorization>

Answer: A

QUESTION 66You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.When you review the application performance counters, you discover that there is an unexpected increase inthe value of the Application Restarts counter.You need to identify the reasons for this increase.What are three possible reasons that could cause this increase? (Each correct answer presents a completesolution. Choose three.)

A. Restart of the Microsoft IIS 6.0 host.B. Restart of the Microsoft Windows Server 2003 that hosts the Web application.C. Addition of a new assembly in the Bin directory of the application.D. Addition of a code segment that requires recompilation to the ASP.NET Web application.E. Enabling of HTTP compression in the Microsoft IIS 6.0 manager for the application.F. Modification to the Web.config file in the system.web section for debugging the application.

Answer: CDF

QUESTION 67You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You plan to monitor the execution of the application at daily intervals.You need to modify the application configuration to enable WebEvent monitoring.What should you do?

A. Enable the Debugging in the Web site option in the ASP.NET configuration settings. Modify the Request Execution timeout to 10 seconds.Register the aspnet_perf.dll performance counter library by using the following command.

B. regsvr32 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_perf.dll Add the following code fragment to the <healthMonitoring> section of the Web.config file of theapplication.

C. <profiles> <add name="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:10" custom="" /> </profiles> Add the following code fragment to the <system.web> section of the Web.config file of the application.

D. <healthMonitoring enabled="true" heartbeatInterval="10"> <rules> <add name="Heartbeats Default" eventName="Heartbeat" provider="EventLogProvider" profile="Critical"/> </rules> </healthMonitoring>

Answer: DExplanation/Reference:

Page 39: 70562 Questions

[email protected] (IT Chanakya)

QUESTION 68You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You add the following code fragment to the Web.config file of the application (Line numbers are included forreference only).01 <healthMonitoring> 02 <providers> 03 <add name="EventLogProvider" 04 type="System.Web.Management.EventLogWebEventProvider 05 /> 06 <add name="WmiWebEventProvider" 07 type="System.Web.Management.WmiWebEventProvider 08 /> 09 </providers> 10 <eventMappings> 11 12 </eventMappings> 13 <rules> 14 <add name="Security Rule" eventName="Security Event" 15 provider="WmiWebEventProvider" /> 16 <add name="AppError Rule" eventName="AppError Event" 17 provider="EventLogProvider" /> 18 </rules> 19 </healthMonitoring> You need to configure Web Events to meet the following requirements:Security-related Web Events are mapped to Microsoft Windows Management Instrumentation (WMI) events.Web Events caused by problems with configuration or application code are logged into the WindowsApplication Event Log.Which code fragment should you insert at line 11?

A. <add name="Security Event"type="System.Web.Management.WebAuditEvent"/> <add name="AppError Event"type="System.Web.Management.WebRequestErrorEvent"/>

B. <add name="Security Event"type="System.Web.Management.WebAuditEvent"/> <add name="AppError Event"type="System.Web.Management.WebErrorEvent"/>

C. <add name="Security Event"type="System.Web.Management.WebApplicationLifetimeEvent"/> <add name="AppError Event"type="System.Web.Management.WebRequestErrorEvent"/>

D. <add name="Security Event"type="System.Web.Management.WebApplicationLifetimeEvent"/> <add name="AppError Event"type="System.Web.Management.WebErrorEvent"/>

Answer: BExplanation/Reference:System.Web.Management.WebAuditEvent for Security-related Web EventsSystem.Web.Management.WebErrorEvent for Web Events caused by problems with configuration orapplication code

QUESTION 69You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code fragment. (Line numbers are included for reference only.) 01 <asp:UpdatePanel ID="upnData" runat="server" 02 ChildrenAsTriggers="false" UpdateMode="Conditional"> 03 <Triggers> 04 05 </Triggers> 06 <ContentTemplate> 07 <!-- more content here --> 08 <asp:LinkButton ID="lbkLoad" runat="server" Text="Load" 09 onclick="lbkLoad_Click" />

Page 40: 70562 Questions

[email protected] (IT Chanakya)

10 <asp:Button ID="btnSubmit" runat="server" Text="Submit" 11 Width="150px" onclick="btnSubmit_Click" /> 12 </ContentTemplate> 13 </asp:UpdatePanel> 14 <asp:Button ID="btnUpdate" runat="server" Text="Update" 15 Width="150px" onclick="btnUpdate_Click" /> You need to ensure that the requirements shown in the following table are met.

What should you do?

A. Set the value of the ChildrenAsTriggers property in line 02 to false.Add the following code fragment at line 04.<asp:AsyncPostBackTrigger ControlID="btnUpdate" /> <asp:PostBackTrigger ControlID="btnSubmit" />

B. Set the value of the ChildrenAsTriggers property in line 02 to false.Add the following code fragment at line 04.<asp:AsyncPostBackTrigger ControlID="btnSubmit" /> <asp:PostBackTrigger ControlID="btnUpdate" />

C. Set the value of the ChildrenAsTriggers property in line 02 to true.Add the following code fragment at line 04.<asp:AsyncPostBackTrigger ControlID="btnSubmit" /> <asp:PostBackTrigger ControlID="btnUpdate" />

D. Set the value of the ChildrenAsTriggers property in line 02 to true.Add the following code fragment at line 04.<asp:AsyncPostBackTrigger ControlID="btnUpdate" /> <asp:PostBackTrigger ControlID="btnSubmit" />

Answer: DExplanation/Reference:

QUESTION 70You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.You add the following code fragment to an AJAX-enabled Web form. (Line numbers are included for referenceonly.) 01 <asp:ScriptManager ID="scrMgr" runat="server" /> 02 <asp:UpdatePanel ID="updPanel" runat="server" 03 UpdateMode="Conditional"> 04 <ContentTemplate> 05 <asp:Label ID="lblTime" runat="server" /> 06 <asp:UpdatePanel ID="updInnerPanel"07 runat="server" UpdateMode="Conditional"> 08 <ContentTemplate> 09 <asp:Timer ID="tmrTimer" runat="server" 10 Interval="1000" 11 OnTick="tmrTimer_Tick" /> 12 </ContentTemplate> 13 14 </asp:UpdatePanel> 15 </ContentTemplate> 16

Page 41: 70562 Questions

[email protected] (IT Chanakya)

17 </asp:UpdatePanel> The tmrTimer_Tick event handler sets the Text property of the lblTime Label control to the current time of theserver.You need to configure the appropriate UpdatePanel control to ensure that the lblTime Label Control isproperly updated by the tmrTimer Timer control.What should you do?

A. Set the UpdateMode="Always" attribute to the updInnerPanel UpdatePanel control in line 07.B. Set the ChildrenAsTriggers="false" attribute to the updPanel UpdatePanel control in line 02.C. Add the following code fragment to line 13.

<Triggers> <asp:PostBackTrigger ControlID="tmrTimer" /> </Triggers>D. Add the following code fragment to line 16.

<Triggers> <asp:AsyncPostBackTrigger ControlID="tmrTimer" EventName="Tick" /> </Triggers>

Answer: DExplanation/Reference:

QUESTION 71You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You write the following code segment to create a client-script function. (Line numbers are included forreference only.) 01 function updateLabelControl(labelId, newText) { 02 var label = $find(labelId); 03 label.innerHTML = newText; 04 } The client script function uses ASP.NET AJAX and updates the text of any Label control in the Web form.When you test the client script function, you discover that the Label controls are not updated.You receive the following JavaScript error message in the browser: "'null' is null or not an object." You need toresolve the error.What should you do?

A. Replace line 03 with the following line of code.label.innerText = newText;

B. Replace line 02 with the following line of code.var label = $get(labelId);

C. Replace line 02 with the following line of code.var label = Sys.UI.DomElement.getElementById($get(labelId));

D. Replace line 02 with the following line of code.var label = Sys.UI.DomElement.getElementById($find(labelId));

Answer: BExplanation/Reference:

QUESTION 72You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web form by using ASP.NET AJAX.You write the following client-script code fragment to handle the exceptions thrown from asynchronouspostbacks. (Line numbers are included for reference only.) 01 <script type="text/javascript"> 02 function pageLoad() 03 { 04 var pageMgr =

Page 42: 70562 Questions

[email protected] (IT Chanakya)

05 Sys.WebForms.PageRequestManager.getInstance(); 06 07 } 08 09 function errorHandler(sender, args) 10 { 11 12 } 13 </script> You need to ensure that the application performs the following tasks:Use a common clien-script function named errorHandler.Update a Label control that has an ID named lblEror with the error message.Prevent the browser from displaying any message box or Javascript error What should you do?

A. Insert the following code segment at line 06.pageMgr.add_endRequest(errorHandler); Insert the following code segment at line 11.if (args.get_error() != null) { $get('lblError').innerHTML = args.get_error().message; args.set_errorHandled(true); }

B. Insert the following code segment at line 06.pageMgr.add_endRequest(errorHandler); Insert the following code segment at line 11.if (args.get_error() != null) { $get('lblError').innerHTML = args.get_error().message; }

C. Insert the following code segment at line 06.pageMgr.add_pageLoaded(errorHandler); Insert the following code segment at line 11.if (args.get_error() != null) { $get('lblError').innerHTML = args.get_error().message; args.set_errorHandled(true); }

D. Insert the following code segment at line 06.pageMgr.add_pageLoaded(errorHandler); Insert the following code segment at line 11.if (args.get_error() != null) { $get('lblError').innerHTML = args.get_error().message; }

Answer: AExplanation/Reference:

QUESTION 73You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a Web form by using ASP.NET AJAX.The Web form contains the following code fragment. (Line numbers are included for reference only.) 01 <script type="text/javascript"> 02 03 Sys.Application.add_init(initComponents); 04 05 function initComponents() { 06 07 } 08

Page 43: 70562 Questions

[email protected] (IT Chanakya)

09 </script> 10 11 <asp:ScriptManager ID="ScriptManager1" 12 runat="server" /> 13 <asp:TextBox runat="server" ID="TextBox1" /> You need to create and initialize a client behavior named MyCustomBehavior by using the initComponentsfunction. You also need to ensure that MyCustomBehavior is attached to the TextBox1 Textbox control.Which code segment should you insert at line 06?

A. $create(MyCustomBehavior, null, null, null, 'TextBox1');B. $create(MyCustomBehavior, null, null, null, $get('TextBox1'));C. Sys.Component.create(MyCustomBehavior, 'TextBox1', null, null, null);D. Sys.Component.create(MyCustomBehavior, $get('TextBox1'), null, null, null);

Answer: BExplanation/Reference:

QUESTION 74You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a login Web form by using the following code fragment.<asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:TextBox runat="server" ID="txtUser" Width="200px" /> <asp:TextBox runat="server" ID="txtPassword" Width="200px" /> <asp:Button runat="server" ID="btnLogin" Text="Login" OnClientClick="login(); return false;" /> When a user clicks the btnLogin Button control, the login() client-side script is called to authenticate the user.The credentials provided in the TextBox controls are used to call the client-side script.You also add the following client-script code fragment in the Web form. (Line numbers are included forreference only.) 01 <script type="text/javascript"> 02 function login() { 03 var username = $get('txtUser').value; 04 var password = $get('txtPassword').value; 05 06 // authentication logic.07 } 08 function onLoginCompleted(validCredentials, userContext, 09 methodName) 10 { 11 // notify user on authentication result.12 } 13 14 function onLoginFailed(error, userContext, methodName) 15 { 16 // notify user on authentication exception.17 } 18 </script> The ASP.NET application is configured to use Forms Authentication. The ASP.NET AJAX authenticationservice is activated in the Web.config file.You need to ensure that the following workflow is maintained:On successful authentication, the onLoginCompleted clien-script function is called to notify the user.On failure of authentication, the onLoginFailed clien-script function is called to display an error message.Which code segment should you insert at line 06?

Page 44: 70562 Questions

[email protected] (IT Chanakya)

A. var auth = Sys.Services.AuthenticationService;auth.login(username, password, false, null, null,onLoginCompleted, onLoginFailed, null);

B. var auth = Sys.Services.AuthenticationService;auth.set_defaultFailedCallback(onLoginFailed); var validCredentials = auth.login(username, password, false, null, null, null, null, null); if (validCredentials) onLoginCompleted(true, null, null); else onLoginCompleted(false, null, null);

C. var auth = Sys.Services.AuthenticationService; auth.set_defaultLoginCompletedCallback(onLoginCompleted); try { auth.login(username, password, false, null, null, null, null, null); } catch (err) { onLoginFailed(err, null, null); }

D. var auth = Sys.Services.AuthenticationService; try { var validCredentials = auth.login(username, password, false, null, null, null, null, null); if (validCredentials) onLoginCompleted(true, null, null); else onLoginCompleted(false, null, null); } catch (err) { onLoginFailed(err, null, null); }

Answer: AExplanation/Reference:Sys.Services.AuthenticationService.login(userName, password, isPersistent,customInfo, redirectUrl, loginCompletedCallback, failedCallback, userContext);

userName (required) The user name to authenticate. password The user's password. The default is null. isPersistent true if the issued authentication ticket should be persistent across browser sessions; otherwise, false. Thedefault is false. redirectUrl The URL to redirect the browser to on successful authentication. If null, no redirect occurs. The default is null. customInfo Reserved for future use. The default is null. loginCompletedCallback The function to call when the login has finished successfully. The default is null. failedCallback The function to call if the login fails. The default is null. userContext User context information that you are passing to the callback functions.

QUESTION 75You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.The application contains the following device filter element in the Web.config file.<filter name="isHtml" compare="PreferredRenderingType"argument="html32" /> The application contains a Web page that has the following image control. (Line numbers are included forreference only.) 01 <mobile:Image ID="imgCtrl" Runat="server"> 02 03 </mobile:Image>

Page 45: 70562 Questions

[email protected] (IT Chanakya)

You need to ensure that the following conditions are met:The imgCtrl Image control displays the highRes.jpg file if the Web browser supports html The imgCtrl Image control displays lowRes.gif if the Web broser does not support html.Which DeviceSpecific element should you insert at line 02?

A. <DeviceSpecific> <Choice Filter="isHtml" ImageUrl="highRes.jpg" /> <Choice ImageUrl="lowRes.gif" /> </DeviceSpecific>

B. <DeviceSpecific> <Choice Filter="isHtml" Argument="false" ImageUrl="highRes.jpg" /> <Choice Filter="isHtml" Argument="true" ImageUrl="lowRes.gif" /> </DeviceSpecific>

C. <DeviceSpecific> <Choice Filter="PreferredRenderingType" ImageUrl="highRes.jpg" /> <Choice ImageUrl="lowRes.gif" /> </DeviceSpecific>

D. <DeviceSpecific> <Choice Filter="PreferredRenderingType" Argument="false" ImageUrl="highRes.jpg" /> <Choice Filter="PreferredRenderingType" Argument="true" ImageUrl="lowRes.gif" /> </DeviceSpecific>

Answer: AExplanation/Reference:

QUESTION 76You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication contains a mobile Web page.You add the following StyleSheet control to the Web page.<mobile:StyleSheet id="MyStyleSheet" runat="server"> <mobile:Style Name="StyleA" Font-Name="Arial" Font-Bold="True" Wrapping="NoWrap"> </mobile:Style> </mobile:StyleSheet> You need to add a Label control named MyLabel that uses the defined style in the MyStyleSheet StyleSheetcontrol.Which markup should you use?

A. <mobile:Label ID="MyLabel" Runat="server"StyleReference="MyStyleSheet:StyleA"> </mobile:Label>B. <mobile:Label ID="MyLabel" Runat="server" StyleReference="StyleA"> </mobile:Label>C. <mobile:Label ID="MyLabel" Runat="server">

<DeviceSpecific ID="DSpec" Runat="server"> <Choice Filter="MyStyleSheet" StyleReference="StyleA" /> </DeviceSpecific> </mobile:Label>

D. <mobile:Label ID="MyLabel" Runat="server"> <DeviceSpecific ID="DSpec" Runat="server"> <Choice Argument="StyleA" StyleReference="MyStyleSheet" /> </DeviceSpecific> </mobile:Label>

Answer: AExplanation/Reference:

Page 46: 70562 Questions

[email protected] (IT Chanakya)

QUESTION 77You modify an existing Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You add a theme to the ASP.NET application.You need to apply the theme to override any settings of individual controls.What should you do?

A. In the Web.config file of the application, set the Theme attribute of the pages element to the name of thetheme.

B. In the Web.config file of the application, set the StyleSheetTheme attribute of the pages element to thename of the theme.

C. Add a master page to the application. In the @Master directive, set the Theme attribute to the name of thetheme.

D. Add a master page to the application. In the @Master directive, set the StyleSheetTheme attribute to thename of the theme.

Answer: A

QUESTION 78You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application uses 10 themes and allows the users to select their themes for the Web page.When a user returns to the application, the theme selected by the user is used to display pages in theapplication. This occurs even if the user returns to log on at a later date or from a different client computer.The application runs on different storage types and in different environments.You need to store the themes that are selected by the users and retrieve the required theme.What should you do?

A. Use the Application object to store the name of the theme tha is selected by the user.B. Retrieve the required theme name from the Application object each time the user visits a pageC. Use the Session object to store the name of the theme that is selected by the user.D. Retrieve the required theme name fro the Session object each time the user visits a page.E. Use the Response.Cookies collection to store the name of the theme that is selected by the user.F. Use the Request. Cookies collection to identify the theme that was selected by the user each time the user

visits a page.G. Add a setting for the theme to the profile section of the Web.config file of the application.H. Use the Profile.Theme string theme to store the name of the theme that is selected by the user.I. Retrieve the required theme name each time the user visits a page.

Answer: GHExplanation/Reference:

QUESTION 79You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application must redirect the original URL to a different ASPX page.You need to ensure that the users cannot view the original URL after the page is executed.You also need to ensure that each page execution requires only one request from the client browser.What should you do?

A. Use the Server.Transfer method to transfer execution to the correct ASPX page.B. Use the Response.Redirect method to transfer execution to the correct ASPX page.

Page 47: 70562 Questions

[email protected] (IT Chanakya)

C. Use the HttpContext.Current.RewritePath method to transfer execution to the correct ASPX page.D. Add the Location: new URL value to the Response.Headers collection. Call the Response.End() statement.

Send the header to the client computer to transfer execution to the correct ASPX page.

Answer: CExplanation/Reference:The RewritePath method redirects a request for a resource to another resource without changing the URL. Ifyou need to reset the virtual path so that client resources resolve correctly, use the overload of this methodthat takes the rebaseClientPath parameter and set the parameter to false.

QUESTION 80You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application uses Session objects. You are modifying the application to run on a Web farm.You need to ensure that the application can access the Session objects from all the servers in the Web farm.You also need to ensure that when any server in the Web farm restarts or stops responding, the Sessionobjects are not lost.What should you do?

A. Use the InProc Session Management mode to store session data in the ASP.NET worker process.B. Use the SQLServer Session Management mode to store session data in a common Microsoft SQL Server

2005 database.C. Use the SQLServer Session Management mode to store session data in an individual database for each

Web server in the Web farm.D. Use the StateServer Session Management mode to store session data in a common State Server process

on a Web server in the Web farm.

Answer: B

QUESTION 81You create a Microsoft ASP.NET Web application by using the Microsoft .NET Framework version 3.5.The Web site uses C# as the programming language. You plan to add a code file written in Microsoft VB.NETto the application. This code segment will not be converted to C#.You add the following code fragment to the Web.config file of the application.<compilation debug="false"> <codeSubDirectories> <add directoryName="VBCode"/> </codeSubDirectories> </compilation> You need to ensure that the following requirements are met:The existing VB.NET file can be used in the Web application The file can be modified and compiled at runtime What should you do?

A. Create a new folder named VBCode at the root of the application Place the VB.NET code file n this newfolder.

B. Create a new folder named VBCode inside the App_Code folder of the application Place the VB.NETcode file in this new folder

C. Create a new class library that uses VB.NET as the programming language Add the VB.NET code ile tothe class library.Add a reference to the class library in the application

D. Create a new Microsoft Windows Communication Foundation ( WCF) service project that uses VB.NET asthe programming language.Expose the VB.NET code functionalitythrough the WCF service.Add a service reference to the WCF service project in the application

Page 48: 70562 Questions

[email protected] (IT Chanakya)

Answer: BExplanation/Reference:

QUESTION 82You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.The application uses a set of general-purpose utility classes that implement business logic.These classes are modified frequently.You need to ensure that the application is recompiled automatically when a utility class is modified.What should you do?

A. Create the Web application by using a Microsoft Visual Studio ASP.NET Web site Add the utility classesto the App_Code subfolder of the Web application

B. Create the Web aplication by using a Microsoft Visual Studio ASP.NET Web Application project.Add the utility classes to the App_Code subfolder of the Web application

C. Create the Web application by using a Microsoft Visual Studio ASP.NET Web site Add the utilty classesto the root folder of the Web application.

D. Create the Web application by using a Microsoft Visual Studio ASP.NET Web Application project Add theutility classes to the root folder of the Web application

Answer: A

QUESTION 83You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You add a Web page named HomePage.aspx in the application. The Web page contains different controls.You add a newly created custom control named CachedControl to the Web page.You need to ensure that the following requirements are met:The custom control state remains static for one minute The custom control settings do not affect the cachesettings of other elements in the Web page What should you do?

A. Add the following code fragment to the Web.config file of the solution.<caching> <outputCacheSettings> <outputCacheProfiles> <add name="CachedProfileSet" varyByControl="CachedControl" duration="60" /> </outputCacheProfiles> </outputCacheSettings> </caching>

B. Add the following code fragment to the Web.config file of the solution.<caching> <outputCacheSettings> <outputCacheProfiles> <add name="CachedProfileSet" varyByParam="CachedControl" duration="60" /> </outputCacheProfiles> </outputCacheSettings> </caching>

C. Add a class named ProfileCache that inherits from the ConfigurationSection class to the HomePage.aspx.cs page.Add the following to the Web.config file of the solution.<ProfileCache profile="CachedProfileSet" varyByControl="CachedControl" duration="60"> </ProfileCache> <caching> <outputCache enableOutputCache="true"/> </caching>

Page 49: 70562 Questions

[email protected] (IT Chanakya)

D. Add a class named ProfileCache that inherits from the ConfigurationSection class to the HomePage.aspx.cs page.Add the following code fragment to the Web.config file of the solution.<ProfileCache profile="CachedProfileSet" varyByParam="CachedControl" duration="60"> </ProfileCache> <caching> <outputCache enableOutputCache="true"/> </caching>

Answer: AExplanation/Reference: