70 562

1,931 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,931
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
106
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

70 562

  1. 1. 1. You 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">0203 </script>04 <asp:ListView ID="ListView1" runat="server"05 DataSourceID="SqlDataSource1"0607 >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"); | English | Chinese | Japan | Korean | -2- Test Information Co., Ltd. All rights reserved.
  2. 2. 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; } | English | Chinese | Japan | Korean | -3- Test Information Co., Ltd. All rights reserved.
  3. 3. }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: A2. You 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">0203 </script>04 <asp:ListView ID="ListView1" runat="server"05 DataSourceID="SqlDataSource1"0607 >08 <ItemTemplate>09 <td>10 <asp:Label ID="LineTotalLabel" runat="server"11 Text=<%# Eval("LineTotal") %> /> | English | Chinese | Japan | Korean | -4- Test Information Co., Ltd. All rights reserved.
  4. 4. 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 Sub FmtClr(ByVal sender As Object, _ByVal e As ListViewItemEventArgs) Dim LineTotal As Label = _ DirectCast(e.Item.FindControl("LineTotalLabel"), Label) If LineTotal IsNot Nothing Then If LineTotal.Text.Length > 7 Then LineTotal.ForeColor = Color.Red Else LineTotal.ForeColor = Color.Black End If End IfEnd SubB. Insert the following code segment at line 06.OnItemDataBound="FmtClr"Insert the following code segment at line 02.Protected Sub FmtClr(ByVal sender As Object, _ByVal e As ListViewItemEventArgs) Dim LineTotal As Label = _ DirectCast(e.Item.FindControl("LineTotal"), Label) If LineTotal.Text.Length > 7 Then LineTotal.ForeColor = Color.Red | English | Chinese | Japan | Korean | -5- Test Information Co., Ltd. All rights reserved.
  5. 5. Else LineTotal.ForeColor = Color.Black End IfEnd SubC. Insert the following code segment at line 06.OnDataBinding="FmtClr"Insert the following code segment at line 02.Protected Sub FmtClr(ByVal sender As Object, _ByVal e As EventArgs) Dim LineTotal As New Label() LineTotal.ID = "LineTotal" If LineTotal.Text.Length > 7 Then LineTotal.ForeColor = Color.Red Else LineTotal.ForeColor = Color.Black End IfEnd SubD. Insert the following code segment at line 06.OnDataBound="FmtClr"Insert the following code segment at line 02.Protected Sub FmtClr(ByVal sender As Object, _ByVal e As EventArgs) Dim LineTotal As New Label() LineTotal.ID = "LineTotalLabel" If LineTotal.Text.Length > 7 Then LineTotal.ForeColor = Color.Red Else LineTotal.ForeColor = Color.Black End IfEnd SubAnswer: A | English | Chinese | Japan | Korean | -6- Test Information Co., Ltd. All rights reserved.
  6. 6. 3. You 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 namedProducts.You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbersare included for reference only.)01 protected void rptData_ItemDataBound(object sender,02 RepeaterItemEventArgs e)03 {0405 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: B | English | Chinese | Japan | Korean | -7- Test Information Co., Ltd. All rights reserved.
  7. 7. 4.You 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 namedProducts.You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbersare included for reference only.)01 Protected Sub rptData_ItemDataBound(ByVal sender As Object, _02 ByVal e As RepeaterItemEventArgs)0304 If lbl IsNot Nothing Then05 If Integer.Parse(lbl.Text) < 10 Then06 lbl.ForeColor = Color.Red07 End If08 End If09 End SubYou need to retrieve a reference to the lblQuantity Label control into a variable named lbl.Which code segment should you insert at line 03?A. Dim lbl As Label = _TryCast(Page.FindControl("lblQuantity"), Label)B. Dim lbl As Label = _ | English | Chinese | Japan | Korean | -8- Test Information Co., Ltd. All rights reserved.
  8. 8. TryCast(e.Item.FindControl("lblQuantity"), Label)C. Dim lbl As Label = _TryCast(rptData.FindControl("lblQuantity"), Label)D. Dim lbl As Label = _TryCast(e.Item.Parent.FindControl("lblQuantity"), Label)Answer: B5. You 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 createa Web page named Default.aspx.<%@ Page Language="C#" AutoEventWireup="true"CodeFile="Default.aspx.cs" Inherits="_Default" %><html>...<body> <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 Labelcontrols.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); | English | Chinese | Japan | Korean | -9- Test Information Co., Ltd. All rights reserved.
  9. 9. 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: D6. You 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 createa Web page named Default.aspx.<%@ Page Language="VB" AutoEventWireup="true"CodeFile="Default.aspx.vb" Inherits="_Default" %><html>...<body> <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 | English | Chinese | Japan | Korean | - 10 - Test Information Co., Ltd. All rights reserved.
  10. 10. controls.What should you do?A. Write the following code segment in the Init event of the Default.aspx Web page.Dim ctrl As Control = LoadControl("UserCtrl.ascx")Me.Controls.AddAt(1, ctrl)B. Write the following code segment in the Init event of the Default.aspx Web page.Dim ctrl As Control = 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.Dim ctrl As Control = 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.Dim ctrl As Control = LoadControl("UserCtrl.ascx")PlHldr.Controls.Add(ctrl)Answer: D7. You 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 tothe server.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) { | English | Chinese | Japan | Korean | - 11 - Test Information Co., Ltd. All rights reserved.
  11. 11. 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.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);} | English | Chinese | Japan | Korean | - 12 - Test Information Co., Ltd. All rights reserved.
  12. 12. C. protected override void OnLoadComplete(EventArgs e){ base.OnLoadComplete(e); LoadControls();}D. protected override void LoadViewState(object savedState){ base.LoadViewState(savedState); LoadControls();}Answer: D8. You 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 tothe server.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 Sub LoadControls() If ViewState("CtrlA") IsNot Nothing Then Dim c As Control If CBool(ViewState("CtrlA")) = True Then c = LoadControl("UserCtrlA.ascx") Else c = LoadControl("UserCtrlB.ascx") End If c.ID = "Ctrl" | English | Chinese | Japan | Korean | - 13 - Test Information Co., Ltd. All rights reserved.
  13. 13. PlHolder.Controls.Add(c) End IfEnd SubProtected Sub Chk_CheckedChanged(ByVal sender As Object, _ByVal e As EventArgs)ViewState("CtrlA") = Chk.CheckedPlHolder.Controls.Clear()LoadControls()End SubYou need to ensure that the user control that is displayed meets the following requirements:¡¤It is recreated during postback¡¤It retains its state.Which method should you add to the Web page?A. Protected Overloads Overrides Function _SaveViewState() As ObjectLoadControls()Return MyBase.SaveViewState()End FunctionB. Protected Overloads Overrides _Sub Render(ByVal writer As HtmlTextWriter)LoadControls()MyBase.Render(writer)End SubC. Protected Overloads Overrides Sub _OnLoadComplete(ByVal e As EventArgs)MyBase.OnLoadComplete(e)LoadControls()End SubD. Protected Overloads Overrides Sub _ | English | Chinese | Japan | Korean | - 14 - Test Information Co., Ltd. All rights reserved.
  14. 14. LoadViewState(ByVal savedState As Object)MyBase.LoadViewState(savedState)LoadControls()End SubAnswer: D9. You 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 theMyControl class. (Line numbers are included for reference only.)01 protected override void02 CreateChildControls() {03 Controls.Clear();04 OrderFormData oFData = new05 ?OrderFormData("OrderForm");0607 }You need to add the OrderFormData control to the MyControl control.Which code segment should you insert at line 06?A. Controls.Add(oFData);B. Template.InstantiateIn(this); Template.InstantiateIn(oFData);C. Controls.Add(oFData); this.Controls.Add(oFData);D. this.TemplateControl = (TemplateControl)Template; oFData.TemplateControl = (TemplateControl)Template; Controls.Add(oFData); | English | Chinese | Japan | Korean | - 15 - Test Information Co., Ltd. All rights reserved.
  15. 15. Answer: B10. You 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 theMyControl class. (Line numbers are included for reference only.)01 Protected Overloads Overrides Sub CreateChildControls()02 Controls.Clear()03 Dim oFData As New OrderFormData("OrderForm")0405 End SubYou need to add the OrderFormData control to the MyControl control.Which code segment should you insert at line 04?A. Controls.Add(oFData)B. Template.InstantiateIn(Me) Template.InstantiateIn(oFData)C. Controls.Add(oFData) Me.Controls.Add(oFData)D. Me.TemplateControl = DirectCast(Template, TemplateControl) oFData.TemplateControl = DirectCast(Template, TemplateControl) Controls.Add(oFData)Answer: B11. You 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? | English | Chinese | Japan | Korean | - 16 - Test Information Co., Ltd. All rights reserved.
  16. 16. A. protected override void CreateChildControls() {Controls.Clear();OrderFormData oFData = new OrderFormData("OrderForm");Controls.Add(oFData);}B. protected override voidRenderContents(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 ControlCollectionCreateControlCollection() {ControlCollection controls = new ControlCollection(this);OrderFormData oFData = new OrderFormData("OrderForm");controls.Add(oFData);return controls;}Answer: A12. You 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. | English | Chinese | Japan | Korean | - 17 - Test Information Co., Ltd. All rights reserved.
  17. 17. Which code segment should you use?A. Protected Overloads Overrides Sub _ CreateChildControls() Controls.Clear() Dim oFData As New OrderFormData("OrderForm") Controls.Add(oFData)End SubB. Protected Overloads Overrides Sub _ RenderContents(ByVal writer As HtmlTextWriter) Dim oFData As New OrderFormData("OrderForm") oFData.RenderControl(writer)End SubC. Protected Overloads Overrides Sub _ EnsureChildControls() Controls.Clear() Dim oFData As New OrderFormData("OrderForm") oFData.EnsureChildControls() If Not ChildControlsCreated Then CreateChildControls() End IfEnd SubD. Protected Overloads Overrides Function _ CreateControlCollection() As ControlCollection Dim controls As New ControlCollection(Me) Dim oFData As New OrderFormData("OrderForm") controls.Add(oFData) Return controlsEnd FunctionAnswer: A| English | Chinese | Japan | Korean | - 18 - Test Information Co., Ltd. All rights reserved.
  18. 18. 13.You 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 voidCheckOrderFormEventHandler(EventArgs e);private static readonly object CheckOrderFormKey= new object();public event CheckOrderFormEventHandlerCheckOrderForm { 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 = | English | Chinese | Japan | Korean | - 19 - Test Information Co., Ltd. All rights reserved.
  19. 19. Events[CheckOrderFormKey] as CheckOrderFormEventHandler; if (checkOrderForm != null) checkOrderForm(e);}C. CheckOrderFormEventHandler checkOrderForm = new CheckOrderFormEventHandler(checkOrderFormCallBack);protected virtual void OnCheckOrderForm(EventArgs e) { if (checkOrderForm != null) checkOrderForm(e);}D. CheckOrderFormEventHandler checkOrderForm =new CheckOrderFormEventHandler(checkOrderFormCallBack);protected virtual void OnCheckOrderForm(EventArgs e) { if (checkOrderForm != null) RaiseBubbleEvent(checkOrderForm, e);}Answer: B14. You 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 Sub _CheckOrderFormEventHandler(ByVal e As EventArgs)Private Shared ReadOnly CheckOrderFormKey As New Object()public event CheckOrderFormEventHandlerPublic Custom Event CheckOrderForm As CheckOrderFormEventHandler AddHandler(ByVal value As CheckOrderFormEventHandler) Events.[AddHandler](CheckOrderFormKey, value) End AddHandler | English | Chinese | Japan | Korean | - 20 - Test Information Co., Ltd. All rights reserved.
  20. 20. RemoveHandler(ByVal value As CheckOrderFormEventHandler) Events.[RemoveHandler](CheckOrderFormKey, value) End RemoveHandler RaiseEvent(ByVal e As EventArgs) End RaiseEventEnd EventYou need to provide a method that enables the OrderForm control to raise the CheckOrderForm event.Which code segment should you use?A. Protected Overridable Sub _ OnCheckOrderForm(ByVal e As EventArgs) Dim checkOrderForm As CheckOrderFormEventHandler = _ DirectCast(Events(GetType(CheckOrderFormEventHandler)), _ CheckOrderFormEventHandler) RaiseEvent CheckOrderForm(e)End SubB. Protected Overridable Sub _ OnCheckOrderForm(ByVal e As EventArgs) Dim checkOrderForm As CheckOrderFormEventHandler = _ TryCast(Events(CheckOrderFormKey), _ CheckOrderFormEventHandler) RaiseEvent CheckOrderForm(e)End SubC. Private checkOrderForm As New _ CheckOrderFormEventHandler(AddressOf _ checkOrderFormCallBack)Protected Overridable Sub _ OnCheckOrderForm(ByVal e As EventArgs) If checkOrderForm IsNot Nothing Then checkOrderForm(e)| English | Chinese | Japan | Korean | - 21 - Test Information Co., Ltd. All rights reserved.
  21. 21. End IfEnd SubD. Private checkOrderForm As New _ CheckOrderFormEventHandler(AddressOf _ checkOrderFormCallBack)Protected Overridable Sub _ OnCheckOrderForm(ByVal e As EventArgs) If checkOrderForm IsNot Nothing Then RaiseBubbleEvent(checkOrderForm, e) End IfEnd SubAnswer: B15. You 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>B. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" | English | Chinese | Japan | Korean | - 22 - Test Information Co., Ltd. All rights reserved.
  22. 22. 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>D. <asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date"EnableClientScript="true" ControlToValidate="TextBox1" Operator="DataTypeCheck" ></asp:CompareValidator>E. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>F. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"ControlToValidate="TextBox1" EnableClientScript="false" InitialValue="<%= DateTime.Now; %>" ></asp:RequiredFieldValidator>G. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>H. <asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date"EnableClientScript="true" ControlToValidate="TextBox1" ValueToCompare="<%= DateTime.Now; %>"></asp:CompareValidator>Answer: B16. You 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 Sub _ | English | Chinese | Japan | Korean | - 23 - Test Information Co., Ltd. All rights reserved.
  23. 23. CustomValidator1_ServerValidate(ByVal source As Object, _ ByVal args As ServerValidateEventArgs) Dim dt As DateTime = _ IIf([String].IsNullOrEmpty(args.Value), _ DateTime.Now, Convert.ToDateTime(args.Value)) args.IsValid = (DateTime.Now - dt).Days < 10End SubYou 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>B. <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>D. <asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date"EnableClientScript="true" ControlToValidate="TextBox1" Operator="DataTypeCheck" ></asp:CompareValidator>E. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>F. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" | English | Chinese | Japan | Korean | - 24 - Test Information Co., Ltd. All rights reserved.
  24. 24. ControlToValidate="TextBox1" EnableClientScript="false" InitialValue="<%= DateTime.Now; %>" ></asp:RequiredFieldValidator>G. <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>H. <asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date"EnableClientScript="true" ControlToValidate="TextBox1" ValueToCompare="<%= DateTime.Now; %>"></asp:CompareValidator>Answer: B17. You 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.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; | English | Chinese | Japan | Korean | - 25 - Test Information Co., Ltd. All rights reserved.
  25. 25. }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: C18. You 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.The validation logic for the control is implemented in the Validate method in the following manner.Protected Overloads Function Validate( _ ByVal value As String) As Boolean ...End FunctionYou need to override the method that validates the value of the related control.Which override method should you use?A. Protected Overloads Overrides Function EvaluateIsValid() As Boolean Dim value As String = _ GetControlValidationValue(Me.Attributes("AssociatedControl")) Dim isValid As Boolean = Validate(value) | English | Chinese | Japan | Korean | - 26 - Test Information Co., Ltd. All rights reserved.
  26. 26. Return isValidEnd FunctionB. Protected Overloads Overrides _ Function ControlPropertiesValid() As Boolean Dim value As String = _ GetControlValidationValue(Me.ValidationGroup) Dim isValid As Boolean = Validate(value) Return isValidEnd FunctionC. Protected Overloads Overrides Function EvaluateIsValid() As Boolean Dim value As String = _ GetControlValidationValue(Me.ControlToValidate) Dim isValid As Boolean = Validate(value) Return isValidEnd FunctionD. Protected Overloads Overrides Function ControlPropertiesValid() As Boolean Dim value As String = _ GetControlValidationValue(Me.Attributes("ControlToValidate")) Dim isValid As Boolean = Validate(value) Me.PropertiesValid = isValid Return TrueEnd FunctionAnswer: C19. You 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 boundto an XML document with the following structure.<?xml version="1.0" encoding="utf-8" ?><clients>| English | Chinese | Japan | Korean | - 27 - Test Information Co., Ltd. All rights reserved.
  27. 27. <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" | English | Chinese | Japan | Korean | - 28 - Test Information Co., Ltd. All rights reserved.
  28. 28. DataTextField="ID" DataValueField="Name" onclick="BulletedList1_Click"> </asp:BulletedList>Answer: C20. You 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 boundto 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 Sub BulletedList1_Click(ByVal sender As _?Object, ByVal e As BulletedListEventArgs) ...End SubYou 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" | English | Chinese | Japan | Korean | - 29 - Test Information Co., Ltd. All rights reserved.
  29. 29. 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: C21. You 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><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 theListBox1 control to the ListBox2 control.Which code segment should you use?A. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { | English | Chinese | Japan | Korean | - 30 - Test Information Co., Ltd. All rights reserved.
  30. 30. 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) { li.Selected = false; ListBox2.Items.Add(li); }}F. foreach (ListItem li in ListBox1.Items) { if (ListBox2.Items.Contains(li)) | English | Chinese | Japan | Korean | - 31 - Test Information Co., Ltd. All rights reserved.
  31. 31. ListBox1.Items.Remove(li);}Answer: C22. You 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><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 theListBox1 control to the ListBox2 control.Which code segment should you use?A. For Each li As ListItem In ListBox1.Items If li.Selected Then ListBox2.Items.Add(li) ListBox1.Items.Remove(li) End IfNextB. For Each li As ListItem In ListBox1.Items If li.Selected Then li.Selected = False ListBox2.Items.Add(li) ListBox1.Items.Remove(li) End IfNext | English | Chinese | Japan | Korean | - 32 - Test Information Co., Ltd. All rights reserved.
  32. 32. C. For Each li As ListItem In ListBox1.Items If li.Selected Then li.Selected = False ListBox2.Items.Add(li) End IfNextD. For Each li As ListItem In ListBox2.Items If ListBox1.Items.Contains(li) Then ListBox1.Items.Remove(li) End IfNextE. For Each li As ListItem In ListBox1.Items If li.Selected Then li.Selected = False ListBox2.Items.Add(li) End IfNextF. For Each li As ListItem In ListBox1.Items If ListBox2.Items.Contains(li) Then ListBox1.Items.Remove(li) End IfNextAnswer: C23. You 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= | English | Chinese | Japan | Korean | - 33 - Test Information Co., Ltd. All rights reserved.
  33. 33. ?"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 DropDownListcontrol.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: A24. You 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> | English | Chinese | Japan | Korean | - 34 - Test Information Co., Ltd. All rights reserved.
  34. 34. </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 DropDownListcontrol.Which code segment should you use?A. Dim idx As Integer = DropDownList1.SelectedIndexMultiView1.ActiveViewIndex = idxB. Dim idx As Integer = DropDownList1.SelectedIndexMultiView1.Views(idx).Visible = TrueC. Dim idx As Integer = Integer.Parse(DropDownList1.SelectedValue)MultiView1.ActiveViewIndex = idxD. Dim idx As Integer = Integer.Parse(DropDownList1.SelectedValue)MultiView1.Views(idx).Visible = TrueAnswer: A25. You 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?A. Add the following code segment to the Calendar1 DayRender event handler.if (e.Day.IsWeekend) { e.Day.IsSelectable = false;}B. Add the following code segment to the Calendar1 DayRender event handler.if (e.Day.IsWeekend) { | English | Chinese | Japan | Korean | - 35 - Test Information Co., Ltd. All rights reserved.
  35. 35. 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: A26. You 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. | English | Chinese | Japan | Korean | - 36 - Test Information Co., Ltd. All rights reserved.
  36. 36. <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?A. Add the following code segment to the Calendar1 DayRender event handler.If e.Day.IsWeekend Then e.Day.IsSelectable = FalseEnd IfB. Add the following code segment to the Calendar1 DayRender event handler.If e.Day.IsWeekend Then If Calendar1.SelectedDates.Contains(e.Day.Date) Then Calendar1.SelectedDates.Remove(e.Day.Date) End IfEnd IfC. Add the following code segment to the Calendar1 SelectionChanged event handler.Dim list As New List(Of DateTime)()For Each st As DateTime In TryCast(sender, Calendar).SelectedDates If st.DayOfWeek = DayOfWeek.Saturday OrElse _ st.DayOfWeek = DayOfWeek.Sunday Then list.Add(st) End IfNextFor Each dt As DateTime In list TryCast(sender, Calendar).SelectedDates.Remove(dt)NextD. Add the following code segment to the Calendar1 DataBinding event handler.Dim list As New List(Of DateTime)()For Each st As DateTime In TryCast(sender, Calendar).SelectedDates| English | Chinese | Japan | Korean | - 37 - Test Information Co., Ltd. All rights reserved.
  37. 37. If st.DayOfWeek = DayOfWeek.Saturday OrElse _ st.DayOfWeek = DayOfWeek.Sunday Then list.Add(st) End IfNextFor Each dt As DateTime In list TryCast(sender, Calendar).SelectedDates.Remove(dt)NextAnswer: A27. You 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();B. XmlReader xr = XmlReader.Create(xmlStream);Product boughtProduct = xr.ReadContentAs(typeof(Product), null) as Product; | English | Chinese | Japan | Korean | - 38 - Test Information Co., Ltd. All rights reserved.
  38. 38. 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: C28. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You define the following class.Public Class Product Public Property Price() As Decimal Get End Get Set(ByVal value As Decimal) End Set End PropertyEnd ClassYour 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. Dim dt As New DataTable() | English | Chinese | Japan | Korean | - 39 - Test Information Co., Ltd. All rights reserved.
  39. 39. dt.ExtendedProperties.Add("Type", "Product")dt.ReadXml(xmlStream)lblPrice.Text = dt.Rows(0)("Price").ToString()B. Dim xr As XmlReader = XmlReader.Create(xmlStream)Dim boughtProduct As Product = TryCast( _ xr.ReadContentAs(GetType(Product), Nothing), Product)lblPrice.Text = boughtProduct.Price.ToString()C. Dim xs As New XmlSerializer(GetType(Product))Dim boughtProduct As Product = TryCast( _ xs.Deserialize(xmlStream), Product)lblPrice.Text = boughtProduct.Price.ToString()D. Dim xDoc As New XmlDocument()xDoc.Load(xmlStream)Dim boughtProduct As Product = xDoc.OfType(Of Product)().First()lblPrice.Text = boughtProduct.Price.ToString()Answer: C29. You 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 areincluded for reference only.)01 public object GetData() {02 SqlConnection cnn = new SqlConnection( -) | English | Chinese | Japan | Korean | - 40 - Test Information Co., Ltd. All rights reserved.
  40. 40. 03 string strQuery = "SELECT * FROM Products";0405 }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: C30. You 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" /> | English | Chinese | Japan | Korean | - 41 - Test Information Co., Ltd. All rights reserved.
  41. 41. </asp:ObjectDataSource>You write the following code segment for the GetData method of the DAL class. (Line numbers areincluded for reference only.)01 Public Function GetData() As Object02 Dim cnn As New SqlConnection( -03 Dim strQuery As String = "SELECT * FROM Products"0405 End FunctionYou 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. Dim cmd As New SqlCommand(strQuery, cnn)cnn.Open()Return cmd.ExecuteReader()B. Dim cmd As New SqlCommand(strQuery, cnn)cnn.Open()Return cmd.ExecuteReader(CommandBehavior.KeyInfo)C. Dim da As New SqlDataAdapter(strQuery, cnn)Dim ds As New DataSet()da.Fill(ds)Return dsD. Dim da As New SqlDataAdapter(strQuery, cnn)Dim ds As New DataSet()da.Fill(ds)ds.ExtendedProperties.Add("Sortable", True)Return ds.Tables(0).Select()Answer: C31. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a class that contains the following code segment. (Line numbers are included for reference | English | Chinese | Japan | Korean | - 42 - Test Information Co., Ltd. All rights reserved.
  42. 42. only.)01 public object GetCachedProducts(sqlConnection conn) {0203 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 }1314 public object GetData(SqlCommand prodCmd) {1516 }Each time a Web form has to access a list of products, the GetCachedProducts method is called toprovide this 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]; | English | Chinese | Japan | Korean | - 43 - Test Information Co., Ltd. All rights reserved.
  43. 43. D. SqlDataAdapter da = new SqlDataAdapter(prodCmd); DataSet ds = new DataSet(); da.Fill(ds); return ds;Answer: D32. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.You create a class that contains the following code segment. (Line numbers are included for referenceonly.)01 Public Function GetCachedProducts( _ ByVal conn As SqlConnection) As Object0203 If Cache("products") Is Nothing Then04 Dim cmd As New SqlCommand("SELECT * FROM Products", conn)05 conn.Open()06 Cache.Insert("products", GetData(cmd))07 conn.Close()08 End If09 Return Cache("products")10 End Function1112 Public Function GetData(ByVal prodCmd As SqlCommand) As Object1314 End FunctionEach time a Web form has to access a list of products, the GetCachedProducts method is called toprovide this 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 13?A. Return prodCmd.ExecuteReader() | English | Chinese | Japan | Korean | - 44 - Test Information Co., Ltd. All rights reserved.
  44. 44. Dim dr As SqlDataReaderprodCmd.CommandTimeout = Integer.MaxValueB. dr = prodCmd.ExecuteReader()Return drC. Dim da As New SqlDataAdapter()da.SelectCommand = prodCmdDim ds As New DataSet()Return ds.Tables(0)D. Dim da As New SqlDataAdapter(prodCmd)Dim ds As New DataSet()da.Fill(ds)Return dsAnswer: D33. You 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();0607 rdr.Close();08 cnn.Close();You need to ensure that the gvProducts and gvCategories GridView controls display the data that iscontained in the following two database tables:¡¤The Products database tabl¡¤The Categories database tabl | English | Chinese | Japan | Korean | - 45 - Test Information Co., Ltd. All rights reserved.
  45. 45. Which code segment should you insert at line 06?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: D34. You 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 Dim strQuery As String = "select * from Products;" + _ "select * from Categories"02 Dim cmd As New SqlCommand(strQuery, cnn)03 cnn.Open()04 Dim rdr As SqlDataReader = cmd.ExecuteReader() | English | Chinese | Japan | Korean | - 46 - Test Information Co., Ltd. All rights reserved.
  46. 46. 0506 rdr.Close()07 cnn.Close()You need to ensure that the gvProducts and gvCategories GridView controls display the data that iscontained in the following two database tables:¡¤The Products database tabl¡¤The Categories database tablWhich code segment should you insert at line 05?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: D35. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. | English | Chinese | Japan | Korean | - 47 - Test Information Co., Ltd. All rights reserved.
  47. 47. 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 referenceonly.)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 {1213 }You need to ensure that when the btnSearch Button control is clicked, the records in the gridCitiesGridView control 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();B. DataSet ds = Session["ds"] as DataSet; | English | Chinese | Japan | Korean | - 48 - Test Information Co., Ltd. All rights reserved.
  48. 48. 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: B36. You 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 referenceonly.)01 Protected Sub Page_Load(ByVal sender As Object, _02 ?ByVal e As EventArgs)03 Dim objDS As New DataSet()04 Dim objDA As New SqlDataAdapter(objCmd)05 objDA.Fill(objDS) | English | Chinese | Japan | Korean | - 49 - Test Information Co., Ltd. All rights reserved.
  49. 49. 06 gridCities.DataSource = objDS07 gridCities.DataBind()08 Session("ds") = objDS09 End Sub10 Protected Sub btnSearch_Click(ByVal sender As Object, _11 ByVal e As EventArgs)1213 End SubYou need to ensure that when the btnSearch Button control is clicked, the records in the gridCitiesGridView control are filtered by using the value of the txtSearch TextBox.Which code segment you should insert at line 12?Dim ds As DataSet = TryCast(gridCities.DataSource, DataSet)Dim dv As DataView = ds.Tables(0).DefaultViewdv.RowFilter = "CityName LIKE " + txtSearch.Text + "%"gridCities.DataSource = dvgridCities.DataBind()Dim ds As DataSet = TryCast(Session("ds"), DataSet)Dim dv As DataView = ds.Tables(0).DefaultViewdv.RowFilter = "CityName LIKE " + txtSearch.Text + "%"gridCities.DataSource = dvgridCities.DataBind()Dim dt As DataTable = TryCast(Session("ds"), DataTable)Dim dv As DataView = dt.DefaultViewdv.RowFilter = "CityName LIKE " + txtSearch.Text + "%"gridCities.DataSource = dvgridCities.DataBind()Dim ds As DataSet = TryCast(Session("ds"), DataSet)Dim dt As DataTable = ds.Tables(0)Dim rows As DataRow() = _ | English | Chinese | Japan | Korean | - 50 - Test Information Co., Ltd. All rights reserved.
  50. 50. ?dt.[Select]("CityName LIKE " + txtSearch.Text + "%")gridCities.DataSource = rowsgridCities.DataBind()Answer: B37. You 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")| English | Chinese | Japan | Korean | - 51 - Test Information Co., Ltd. All rights reserved.
  51. 51. 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: A38. You 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()> _Function UpdateCustomerDetails(ByVal custID As String) As StringThe application hosts the WCF service by using the following code segment.Dim host As New WebServiceHost(GetType(CService), _ New Uri("http://win/"))Dim ep As ServiceEndpoint = host.AddServiceEndpoint( _ GetType(ICService), New WebHttpBinding(), "")You need to invoke the UpdateCustomerDetails method.Which code segment should you use?A. dim wcf As New WebChannelFactory(Of ICService)( _ New Uri("http: //win"))Dim channel As ICService = wcf.CreateChannel()Dim s As String = channel.UpdateCustomerDetails("CustID12")B. dim wcf As New WebChannelFactory(Of ICService)( _ New Uri("http: //win/UpdateCustomerDetails"))Dim channel As ICService = wcf.CreateChannel()| English | Chinese | Japan | Korean | - 52 - Test Information Co., Ltd. All rights reserved.
  52. 52. Dim s As String = channel.UpdateCustomerDetails("CustID12")C. Dim cf As New ChannelFactory(Of ICService)( _ New WebHttpBinding(), "http: //win/UpdateCustomerDetails")Dim channel As ICService = cf.CreateChannel()Dim s As String = channel.UpdateCustomerDetails("CustID12")D. Dim cf As New ChannelFactory(Of ICService)( _ New BasicHttpBinding(), "http: //win ")cf.Endpoint.Behaviors.Add(New WebHttpBehavior())Dim channel As ICService = cf.CreateChannel()Dim s As String = channel.UpdateCustomerDetails("CustID12")Answer: A39. You 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 followingservice contract. (Line numbers are included for reference only.)01 [ServiceContract]02 public interface IBlogService03 {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/BlogServiceYou need to store the result of the GetBlog operation in an XmlDocument variable named xmlBlog in aWeb form.Which code segment should you use?A. string url = @"http: //www.contoso.com/BlogService/GetBlog";XmlReader blogReader = XmlReader.Create(url); | English | Chinese | Japan | Korean | - 53 - Test Information Co., Ltd. All rights reserved.
  53. 53. 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: A40. You 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 followingservice contract. (Line numbers are included for reference only.)01 <ServiceContract()> _02 Public Interface IBlogService03 <OperationContract()> _04 <WebGet(ResponseFormat := WebMessageFormat.Xml)> _05 Function GetBlog() As Rss20FeedFormatter06 End InterfaceYou configure the WCF service to use the WebHttpBinding class and to be exposed at the following URL:http://www.contoso.com/BlogService| English | Chinese | Japan | Korean | - 54 - Test Information Co., Ltd. All rights reserved.
  54. 54. You need to store the result of the GetBlog operation in an XmlDocument variable named xmlBlog in aWeb form.Which code segment should you use?A. Dim url As String = "http: //www.contoso.com/BlogService/GetBlog"Dim blogReader As XmlReader = XmlReader.Create(url)xmlBlog.Load(blogReader)B. Dim url As String = "http: //www.contoso.com/BlogService"Dim blogReader As XmlReader = XmlReader.Create(url)xmlBlog.Load(blogReader)C. Dim binding As New BasicHttpBinding()Dim blogUri As New _ EndpointAddress("http: //www.contoso.com/BlogService")Dim blogFactory As New _ ChannelFactory(Of IBlogService)(binding, blogUri)Dim blogSrv As IBlogService = blogFactory.CreateChannel()Dim feed As Rss20FeedFormatter = blogSrv.GetBlog()xmlBlog.LoadXml(feed.ToString())D. Dim binding As New BasicHttpBinding()Dim blogUri As New _ EndpointAddress("http: //www.contoso.com/BlogService/GetBlog")Dim blogFactory As New _ ChannelFactory(Of IBlogService)(binding, blogUri)Dim blogSrv As IBlogService = blogFactory.CreateChannel()Dim feed As Rss20FeedFormatter = blogSrv.GetBlog()xmlBlog.LoadXml(feed.Feed.ToString())Answer: A41. You 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.| English | Chinese | Japan | Korean | - 55 - Test Information Co., Ltd. All rights reserved.
  55. 55. 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);}C. protected override object Evaluate(HttpContext context, Control control) { return DateTime.Now;}D. protected override Parameter Clone(){ Parameter pm = new DayParameter(); | English | Chinese | Japan | Korean | - 56 - Test Information Co., Ltd. All rights reserved.
  56. 56. pm.DefaultValue = DateTime.Now; return pm;}Answer: C42. You 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 Inherits ParameterEnd ClassYou 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 Sub New() MyBase.New("Value", TypeCode.DateTime, DateTime.Now.ToString())End SubB. Protected Overloads Overrides Sub _ LoadViewState(ByVal savedState As Object) DirectCast(savedState, _ | English | Chinese | Japan | Korean | - 57 - Test Information Co., Ltd. All rights reserved.
  57. 57. StateBag).Add("Value", DateTime.Now)End SubC. Protected Overloads Overrides Function _ Evaluate(ByVal context As HttpContext, _ ByVal control As Control) As Object Return DateTime.NowEnd FunctionD. Protected Overloads Overrides Function _ Clone() As Parameter Dim pm As Parameter = New DayParameter() pm.DefaultValue = DateTime.Now Return pmEnd FunctionAnswer: C43. You 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){ | English | Chinese | Japan | Korean | - 58 - Test Information Co., Ltd. All rights reserved.
  58. 58. 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: AC44. You 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 exception information in the Event log fileWhich 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.Public Sub Application_Error(ByVal sender As Object, _ ByVal e As EventArgs) Dim exc As Exception = Server.GetLastError() Write Exception details to event logEnd Sub | English | Chinese | Japan | Korean | - 59 - Test Information Co., Ltd. All rights reserved.
  59. 59. D. Add the following code segment to the ErrorPage.aspx file.Public Sub Page_Error(ByVal sender As Object, _ ByVal e As EventArgs) Dim exc As Exception = Server.GetLastError() Write Exception details to event log Server.ClearError()End SubAnswer: AC45. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication 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 displayedto remote 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" | English | Chinese | Japan | Korean | - 60 - Test Information Co., Ltd. All rights reserved.
  60. 60. 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: C46. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. Theapplication 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 displayedto remote 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="VB" AutoEventWireup="true" CodeFile="OrderDetails.aspx.vb" 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="VB" AutoEventWireup="true" | English | Chinese | Japan | Korean | - 61 - Test Information Co., Ltd. All rights reserved.
  61. 61. CodeFile="OrderDetails.aspx.vb" 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="VB" AutoEventWireup="true" CodeFile="OrderDetails.aspx.vb" 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="VB" AutoEventWireup="true" CodeFile="OrderDetails.aspx.vb" Inherits="OrderDetails" Debug="true" ErrorPage="~/OrderError.htm" %>Add the following section to the Web.config file.<customErrors mode="Off"></customErrors>Answer: C47. You 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" /> | English | Chinese | Japan | Korean | - 62 - Test Information Co., Ltd. All rights reserved.
  62. 62. </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?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); | English | Chinese | Japan | Korean | - 63 - Test Information Co., Ltd. All rights reserved.
  63. 63. Label3.Text = "Label3 updated value";}Answer: B48. You 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?A. Protected Sub btnSubmit_Click(ByVal sender As Object, _ ByVal e As EventArgs) Label1.Text = "Label1 updated value" Label2.Text = "Label2 updated value" Label3.Text = "Label3 updated value"End SubB. Protected Sub btnSubmit_Click(ByVal sender As Object, _ ByVal e As EventArgs) Label1.Text = "Label1 updated value" | English | Chinese | Japan | Korean | - 64 - Test Information Co., Ltd. All rights reserved.
  64. 64. Label2.Text = "Label2 updated value" ScriptManager1.RegisterDataItem(Label3, _ "Label3 updated value")End SubC. Protected Sub btnSubmit_Click(ByVal sender As Object, _ ByVal e As EventArgs) ScriptManager1.RegisterDataItem(Label1, _ "Label1 updated value") ScriptManager1.RegisterDataItem(Label2, _ "Label2 updated value") Label3.Text = "Label3 updated value"End SubD. Protected Sub btnSubmit_Click(ByVal sender As Object, _ ByVal e As EventArgs) Label1.Text = "Label1 updated value" Label2.Text = "Label2 updated value" ScriptManager1.RegisterAsyncPostBackControl(Label3) Label3.Text = "Label3 updated value"End SubAnswer: B49. You 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 areincluded for reference only.)01 <script runat="server">02 protected void Button_Handler(object sender, EventArgs e)03 {04 // some long-processing operation.05 } | English | Chinese | Japan | Korean | - 65 - Test Information Co., Ltd. All rights reserved.
  65. 65. 06 </script>07 <div>08 <asp:ScriptManager ID="defaultScriptManager"09 runat="server" />1011 <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 thebtnSubmit Button control are suppressed.Which code fragment should you insert at line 10?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> | English | Chinese | Japan | Korean | - 66 - Test Information Co., Ltd. All rights reserved.
  66. 66. 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) { | English | Chinese | Japan | Korean | - 67 - Test Information Co., Ltd. All rights reserved.
  67. 67. request.completed(new Sys.CancelEventArgs()); alert(A previous request is still in progress.); } }</script>Answer: C50. You 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 areincluded for reference only.)01 <script runat="server">02 Protected Sub Button_Handler(ByVal sender As Object, _03 ByVal e As EventArgs)04 some long-processing operation.05 End Sub06 </script>07 <div>08 <asp:ScriptManager ID="defaultScriptManager"09 runat="server" />1011 <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> | English | Chinese | Japan | Korean | - 68 - Test Information Co., Ltd. All rights reserved.
  68. 68. 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 thebtnSubmit Button control are suppressed.Which code fragment should you insert at line 10?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); | English | Chinese | Japan | Korean | - 69 - Test Information Co., Ltd. All rights reserved.

×