SlideShare a Scribd company logo
1 of 168
Download to read offline
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 for

reference 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. The

database table has a column named LineTotal.

You need to ensure that when the size of the LineTotal column value is greater than seven characters, the

column 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.
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.
}

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: A



2. 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 for

reference 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") %>' />


    | English | Chinese | Japan | Korean |           -4-           Test Information Co., Ltd. All rights reserved.
12     </td>

13 </ItemTemplate>

The SqlDataSource1 object retrieves the data from a Microsoft SQL Server 2005 database table. The

database table has a column named LineTotal.

You need to ensure that when the size of the LineTotal column value is greater than seven characters, the

column 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 If

End Sub

B. 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.
Else

     LineTotal.ForeColor = Color.Black

  End If

End Sub

C. 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 If

End Sub

D. 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 If

End Sub

Answer: A


 | English | Chinese | Japan | Korean |            -6-           Test Information Co., Ltd. All rights reserved.
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 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: B


 | English | Chinese | Japan | Korean |              -7-               Test Information Co., Ltd. All rights reserved.
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 named

Products.

You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbers

are included for reference only.)

01 Protected Sub rptData_ItemDataBound(ByVal sender As Object, _

02 ByVal e As RepeaterItemEventArgs)

03

04 If lbl IsNot Nothing Then

05 If Integer.Parse(lbl.Text) < 10 Then

06 lbl.ForeColor = Color.Red

07 End If

08 End If

09 End Sub

You 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.
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: B



5. 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 create

a 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 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);


 | English | Chinese | Japan | Korean |              -9-             Test Information Co., Ltd. All rights reserved.
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: D



6. 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 create

a 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.
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: D



7. 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 to

the 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.
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.
C. protected override void OnLoadComplete(EventArgs e)

{

     base.OnLoadComplete(e);

     LoadControls();

}

D. protected override void LoadViewState(object savedState)

{

     base.LoadViewState(savedState);

     LoadControls();

}

Answer: D



8. 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 to

the 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.
PlHolder.Controls.Add(c)

  End If

End Sub

Protected Sub Chk_CheckedChanged(ByVal sender As Object, _

ByVal e As EventArgs)

ViewState("CtrlA") = Chk.Checked

PlHolder.Controls.Clear()

LoadControls()

End Sub

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 Overloads Overrides Function _

SaveViewState() As Object

LoadControls()

Return MyBase.SaveViewState()

End Function

B. Protected Overloads Overrides _

Sub Render(ByVal writer As HtmlTextWriter)

LoadControls()

MyBase.Render(writer)

End Sub

C. Protected Overloads Overrides Sub _

OnLoadComplete(ByVal e As EventArgs)

MyBase.OnLoadComplete(e)

LoadControls()

End Sub

D. Protected Overloads Overrides Sub _


 | English | Chinese | Japan | Korean |            - 14 -             Test Information Co., Ltd. All rights reserved.
LoadViewState(ByVal savedState As Object)

MyBase.LoadViewState(savedState)

LoadControls()

End Sub

Answer: D



9. 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 the

MyControl class. (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. 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.
Answer: B



10. 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 the

MyControl class. (Line numbers are included for reference only.)

01 Protected Overloads Overrides Sub CreateChildControls()

02 Controls.Clear()

03 Dim oFData As New OrderFormData("OrderForm")

04

05 End Sub

You 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: B



11. 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.
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: A



12. 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.
Which code segment should you use?

A. Protected Overloads Overrides Sub _

 CreateChildControls()

  Controls.Clear()

  Dim oFData As New OrderFormData("OrderForm")

  Controls.Add(oFData)

End Sub

B. Protected Overloads Overrides Sub _

 RenderContents(ByVal writer As HtmlTextWriter)

  Dim oFData As New OrderFormData("OrderForm")

  oFData.RenderControl(writer)

End Sub

C. Protected Overloads Overrides Sub _

 EnsureChildControls()

  Controls.Clear()

  Dim oFData As New OrderFormData("OrderForm")

  oFData.EnsureChildControls()

  If Not ChildControlsCreated Then

    CreateChildControls()

  End If

End Sub

D. Protected Overloads Overrides Function _

 CreateControlCollection() As ControlCollection

  Dim controls As New ControlCollection(Me)

  Dim oFData As New OrderFormData("OrderForm")

  controls.Add(oFData)

  Return controls

End Function

Answer: A


| English | Chinese | Japan | Korean |            - 18 -   Test Information Co., Ltd. All rights reserved.
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 void

CheckOrderFormEventHandler(EventArgs e);

private static readonly object CheckOrderFormKey

= 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 =


    | English | Chinese | Japan | Korean |         - 19 -          Test Information Co., Ltd. All rights reserved.
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: B



14. 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 CheckOrderFormEventHandler

Public 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.
RemoveHandler(ByVal value As CheckOrderFormEventHandler)

    Events.[RemoveHandler](CheckOrderFormKey, value)

  End RemoveHandler

  RaiseEvent(ByVal e As EventArgs)

  End RaiseEvent

End Event

You 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 Sub

B. Protected Overridable Sub _

 OnCheckOrderForm(ByVal e As EventArgs)

  Dim checkOrderForm As CheckOrderFormEventHandler = _

  TryCast(Events(CheckOrderFormKey), _

  CheckOrderFormEventHandler)

  RaiseEvent CheckOrderForm(e)

End Sub

C. 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.
End If

End Sub

D. Private checkOrderForm As New _

    CheckOrderFormEventHandler(AddressOf _

    checkOrderFormCallBack)

Protected Overridable Sub _

    OnCheckOrderForm(ByVal e As EventArgs)

     If checkOrderForm IsNot Nothing Then

        RaiseBubbleEvent(checkOrderForm, e)

     End If

End Sub

Answer: B



15. 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.
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: B



16. 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.
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 < 10

End Sub

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"                         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.
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: B



17. 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.
}

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



18. 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 Function

You 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.
Return isValid

End Function

B. Protected Overloads Overrides _

 Function ControlPropertiesValid() As Boolean

  Dim value As String = _

   GetControlValidationValue(Me.ValidationGroup)

  Dim isValid As Boolean = Validate(value)

  Return isValid

End Function

C. Protected Overloads Overrides Function EvaluateIsValid() As Boolean

  Dim value As String = _

   GetControlValidationValue(Me.ControlToValidate)

  Dim isValid As Boolean = Validate(value)

  Return isValid

End Function

D. 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 True

End Function

Answer: C



19. 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 bound

to 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.
<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 to

XmlDataSource1.

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.
DataTextField="ID" DataValueField="Name"

        onclick="BulletedList1_Click">

   </asp:BulletedList>

Answer: C



20. 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 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 Sub BulletedList1_Click(ByVal sender As _

?Object, ByVal e As BulletedListEventArgs)

  '...

End Sub

You need to add a BulletedList control named BulletedList1 to the Web page that is bound to

XmlDataSource1.

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.
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: C



21. 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 the

ListBox1 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.
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.
ListBox1.Items.Remove(li);

}

Answer: C



22. 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 the

ListBox1 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 If

Next

B. For Each li As ListItem In ListBox1.Items

     If li.Selected Then

        li.Selected = False

        ListBox2.Items.Add(li)

        ListBox1.Items.Remove(li)

     End If

Next


    | English | Chinese | Japan | Korean |       - 32 -             Test Information Co., Ltd. All rights reserved.
C. For Each li As ListItem In ListBox1.Items

  If li.Selected Then

     li.Selected = False

     ListBox2.Items.Add(li)

  End If

Next

D. For Each li As ListItem In ListBox2.Items

  If ListBox1.Items.Contains(li) Then

     ListBox1.Items.Remove(li)

  End If

Next

E. For Each li As ListItem In ListBox1.Items

  If li.Selected Then

     li.Selected = False

     ListBox2.Items.Add(li)

  End If

Next

F. For Each li As ListItem In ListBox1.Items

  If ListBox2.Items.Contains(li) Then

     ListBox1.Items.Remove(li)

  End If

Next

Answer: C



23. 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.
?"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 View

controls.

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: A



24. 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.
</asp:DropDownList>

You also add a MultiView control named MultiView1 to the Web page. MultiView1 has three child View

controls.

You need to ensure that you can select the View controls by using the DropDownList1 DropDownList

control.

Which code segment should you use?

A. Dim idx As Integer = DropDownList1.SelectedIndex

MultiView1.ActiveViewIndex = idx

B. Dim idx As Integer = DropDownList1.SelectedIndex

MultiView1.Views(idx).Visible = True

C. Dim idx As Integer = Integer.Parse(DropDownList1.SelectedValue)

MultiView1.ActiveViewIndex = idx

D. Dim idx As Integer = Integer.Parse(DropDownList1.SelectedValue)

MultiView1.Views(idx).Visible = True

Answer: A



25. 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.
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: A



26. 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.
<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 = False

End If

B. 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 If

End If

C. 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 If

Next

For Each dt As DateTime In list

  TryCast(sender, Calendar).SelectedDates.Remove(dt)

Next

D. 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.
If st.DayOfWeek = DayOfWeek.Saturday OrElse _

      st.DayOfWeek = DayOfWeek.Sunday Then

        list.Add(st)

     End If

Next

For Each dt As DateTime In list

     TryCast(sender, Calendar).SelectedDates.Remove(dt)

Next

Answer: A



27. 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.
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: C



28. 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 Property

End Class

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. Dim dt As New DataTable()


 | English | Chinese | Japan | Korean |             - 39 -             Test Information Co., Ltd. All rights reserved.
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: C



29. 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 are

included for reference only.)

01 public object GetData() {

02    SqlConnection cnn = new SqlConnection(     -)


 | English | Chinese | Japan | Korean |           - 40 -            Test Information Co., Ltd. All rights reserved.
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: C



30. 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.
</asp:ObjectDataSource>

You write the following code segment for the GetData method of the DAL class. (Line numbers are

included for reference only.)

01 Public Function GetData() As Object

02 Dim cnn As New SqlConnection(          -

03 Dim strQuery As String = "SELECT * FROM Products"

04

05 End Function

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. 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 ds

D. 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: C



31. 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.
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

provide 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.
D. SqlDataAdapter da = new SqlDataAdapter(prodCmd);

     DataSet ds = new DataSet();

     da.Fill(ds);

     return ds;

Answer: D



32. 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

only.)

01 Public Function GetCachedProducts( _

      ByVal conn As SqlConnection) As Object

02

03       If Cache("products") Is Nothing Then

04         Dim cmd As New SqlCommand("SELECT * FROM Products", conn)

05         conn.Open()

06         Cache.Insert("products", GetData(cmd))

07         conn.Close()

08       End If

09       Return Cache("products")

10 End Function

11

12 Public Function GetData(ByVal prodCmd As SqlCommand) As Object

13

14 End Function

Each time a Web form has to access a list of products, the GetCachedProducts method is called to

provide 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.
Dim dr As SqlDataReader

prodCmd.CommandTimeout = Integer.MaxValue

B. dr = prodCmd.ExecuteReader()

Return dr

C. Dim da As New SqlDataAdapter()

da.SelectCommand = prodCmd

Dim ds As New DataSet()

Return ds.Tables(0)

D. Dim da As New SqlDataAdapter(prodCmd)

Dim ds As New DataSet()

da.Fill(ds)

Return ds

Answer: D



33. 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 are

included 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

contained 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.
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: D



34. 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 are

included 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.
05

06 rdr.Close()

07 cnn.Close()

You need to ensure that the gvProducts and gvCategories GridView controls display the data that is

contained in the following two database tables:

¡¤The Products database tabl

¡¤The Categories database tabl

Which 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: D



35. 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.
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

GridView 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.
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: B



36. 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 reference

only.)

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.
06    gridCities.DataSource = objDS

07    gridCities.DataBind()

08    Session("ds") = objDS

09 End Sub

10 Protected Sub btnSearch_Click(ByVal sender As Object, _

11    ByVal e As EventArgs)

12

13 End Sub

You need to ensure that when the btnSearch Button control is clicked, the records in the gridCities

GridView 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).DefaultView

dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'"

gridCities.DataSource = dv

gridCities.DataBind()

Dim ds As DataSet = TryCast(Session("ds"), DataSet)

Dim dv As DataView = ds.Tables(0).DefaultView

dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'"

gridCities.DataSource = dv

gridCities.DataBind()

Dim dt As DataTable = TryCast(Session("ds"), DataTable)

Dim dv As DataView = dt.DefaultView

dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'"

gridCities.DataSource = dv

gridCities.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.
?dt.[Select]("CityName LIKE '" + txtSearch.Text + "%'")

gridCities.DataSource = rows

gridCities.DataBind()

Answer: B



37. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The

application 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.
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: A



38. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The

application consumes a Microsoft Windows Communication Foundation (WCF) service.

The WCF service exposes the following method.

<WebInvoke()> _

Function UpdateCustomerDetails(ByVal custID As String) As String

The 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.
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: A



39. 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 following

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

Web 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.
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: A



40. 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 following

service contract. (Line numbers are included for reference only.)

01 <ServiceContract()> _

02 Public Interface IBlogService

03    <OperationContract()> _

04    <WebGet(ResponseFormat := WebMessageFormat.Xml)> _

05    Function GetBlog() As Rss20FeedFormatter

06 End Interface

You 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.
You need to store the result of the GetBlog operation in an XmlDocument variable named xmlBlog in a

Web 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: A



41. 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.
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.
pm.DefaultValue = DateTime.Now;

     return pm;

}

Answer: C



42. 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 Parameter

End Class

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 Sub New()

     MyBase.New("Value", TypeCode.DateTime, DateTime.Now.ToString())

End Sub

B. Protected Overloads Overrides Sub _

    LoadViewState(ByVal savedState As Object)

     DirectCast(savedState, _


    | English | Chinese | Japan | Korean |        - 57 -             Test Information Co., Ltd. All rights reserved.
StateBag).Add("Value", DateTime.Now)

End Sub

C. Protected Overloads Overrides Function _

    Evaluate(ByVal context As HttpContext, _

    ByVal control As Control) As Object

     Return DateTime.Now

End Function

D. Protected Overloads Overrides Function _

    Clone() As Parameter

     Dim pm As Parameter = New DayParameter()

     pm.DefaultValue = DateTime.Now

     Return pm

End Function

Answer: C



43. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The

application 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.
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: AC



44. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The

application 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 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.

Public Sub Application_Error(ByVal sender As Object, _

    ByVal e As EventArgs)

     Dim exc As Exception = Server.GetLastError()

     'Write Exception details to event log

End Sub


    | English | Chinese | Japan | Korean |            - 59 -        Test Information Co., Ltd. All rights reserved.
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 Sub

Answer: AC



45. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. 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

to remote users.

You need to ensure that the OrderError.htm Web page is displayed for unhandled errors only in the

OrderDetails.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.
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: C



46. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. 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

to remote users.

You need to ensure that the OrderError.htm Web page is displayed for unhandled errors only in the

OrderDetails.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.
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: C



47. 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.
</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 is

asynchronously 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.
Label3.Text = "Label3 updated value";

}

Answer: B



48. 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 is

asynchronously 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 Sub

B. 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.
Label2.Text = "Label2 updated value"

  ScriptManager1.RegisterDataItem(Label3, _

     "Label3 updated value")

End Sub

C. 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 Sub

D. 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 Sub

Answer: B



49. 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 are

included 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.
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

btnSubmit 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.
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.
request.completed(new Sys.CancelEventArgs());

          alert('A previous request is still in progress.');

      }

  }

</script>

Answer: C



50. 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 are

included 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 Sub

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>


 | English | Chinese | Japan | Korean |                    - 68 -   Test Information Co., Ltd. All rights reserved.
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

btnSubmit 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.
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: C



51. You 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;


 | English | Chinese | Japan | Korean |                     - 70 -    Test Information Co., Ltd. All rights reserved.
}

return a/b;

}

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 the JavaScript 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 the

resource 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: C



52. You 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;


    | English | Chinese | Japan | Korean |          - 71 -            Test Information Co., Ltd. All rights reserved.
}

return a/b;

}

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 the JavaScript 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 the

resource file.

Which code segment should you add in the AssemblyInfo.vb 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: C



53. You 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" />


    | English | Chinese | Japan | Korean |             - 72 -            Test Information Co., Ltd. All rights reserved.
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562
70 562

More Related Content

What's hot

Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NETmentorrbuddy
 
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...Flink Forward
 
Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)Mohamed Saleh
 
Stack Implementation
Stack ImplementationStack Implementation
Stack ImplementationZidny Nafan
 
Reviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseReviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseAlexandra N. Martinez
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherencearagozin
 
Financial modeling sameh aljabli lecture 6
Financial modeling   sameh aljabli   lecture 6Financial modeling   sameh aljabli   lecture 6
Financial modeling sameh aljabli lecture 6Sameh Algabli
 
Microsoft Silverlight
Microsoft SilverlightMicrosoft Silverlight
Microsoft Silverlightguest3a8196
 

What's hot (20)

Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NET
 
Stacks
StacksStacks
Stacks
 
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
 
Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
 
PostThis
PostThisPostThis
PostThis
 
Amusing C#
Amusing C#Amusing C#
Amusing C#
 
Reviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseReviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-case
 
LINQ
LINQLINQ
LINQ
 
Why hibernater1
Why hibernater1Why hibernater1
Why hibernater1
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherence
 
R-Shiny Cheat sheet
R-Shiny Cheat sheetR-Shiny Cheat sheet
R-Shiny Cheat sheet
 
Financial modeling sameh aljabli lecture 6
Financial modeling   sameh aljabli   lecture 6Financial modeling   sameh aljabli   lecture 6
Financial modeling sameh aljabli lecture 6
 
Python openpyxl
Python openpyxlPython openpyxl
Python openpyxl
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 
Capstone ms2
Capstone ms2Capstone ms2
Capstone ms2
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Lab2-android
Lab2-androidLab2-android
Lab2-android
 
Linq
LinqLinq
Linq
 
Microsoft Silverlight
Microsoft SilverlightMicrosoft Silverlight
Microsoft Silverlight
 

Similar to 70 562

R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioRobert Tanenbaum
 
Microsoft MCSE 70-469 it braindumps
Microsoft MCSE 70-469 it braindumpsMicrosoft MCSE 70-469 it braindumps
Microsoft MCSE 70-469 it braindumpslilylucy
 
Developing Microsoft SQL Server 2012 Databases 70-464 Pass Guarantee
Developing Microsoft SQL Server 2012 Databases 70-464 Pass GuaranteeDeveloping Microsoft SQL Server 2012 Databases 70-464 Pass Guarantee
Developing Microsoft SQL Server 2012 Databases 70-464 Pass GuaranteeSusanMorant
 
Useful macros and functions for excel
Useful macros and functions for excelUseful macros and functions for excel
Useful macros and functions for excelNihar Ranjan Paital
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docxAustinaGRPaigey
 
C++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment InstructionsC++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment InstructionsTawnaDelatorrejs
 
data.txtInternational Business Management l2 Cons.docx
data.txtInternational Business Management       l2        Cons.docxdata.txtInternational Business Management       l2        Cons.docx
data.txtInternational Business Management l2 Cons.docxtheodorelove43763
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studioAravindharamanan S
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studioAravindharamanan S
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answersdebarghyamukherjee60
 
Abap programming overview
Abap programming overview Abap programming overview
Abap programming overview k kartheek
 
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoHasnain Iqbal
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationRandy Connolly
 

Similar to 70 562 (20)

R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net Portfolio
 
Microsoft MCSE 70-469 it braindumps
Microsoft MCSE 70-469 it braindumpsMicrosoft MCSE 70-469 it braindumps
Microsoft MCSE 70-469 it braindumps
 
Developing Microsoft SQL Server 2012 Databases 70-464 Pass Guarantee
Developing Microsoft SQL Server 2012 Databases 70-464 Pass GuaranteeDeveloping Microsoft SQL Server 2012 Databases 70-464 Pass Guarantee
Developing Microsoft SQL Server 2012 Databases 70-464 Pass Guarantee
 
KMI System
KMI SystemKMI System
KMI System
 
Useful macros and functions for excel
Useful macros and functions for excelUseful macros and functions for excel
Useful macros and functions for excel
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docx
 
Html css
Html cssHtml css
Html css
 
C++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment InstructionsC++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment Instructions
 
data.txtInternational Business Management l2 Cons.docx
data.txtInternational Business Management       l2        Cons.docxdata.txtInternational Business Management       l2        Cons.docx
data.txtInternational Business Management l2 Cons.docx
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
Abap programming overview
Abap programming overview Abap programming overview
Abap programming overview
 
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
 
ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
RicoLiveGrid
RicoLiveGridRicoLiveGrid
RicoLiveGrid
 

More from Pragya Rastogi (20)

Gl android platform
Gl android platformGl android platform
Gl android platform
 
Qtp questions
Qtp questionsQtp questions
Qtp questions
 
Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
 
Qtp tutorial
Qtp tutorialQtp tutorial
Qtp tutorial
 
Qtp4 bpt
Qtp4 bptQtp4 bpt
Qtp4 bpt
 
Get ro property outputting value
Get ro property outputting valueGet ro property outputting value
Get ro property outputting value
 
Bp ttutorial
Bp ttutorialBp ttutorial
Bp ttutorial
 
Gl istqb testing fundamentals
Gl istqb testing fundamentalsGl istqb testing fundamentals
Gl istqb testing fundamentals
 
Gl scrum testing_models
Gl scrum testing_modelsGl scrum testing_models
Gl scrum testing_models
 
My Sql concepts
My Sql conceptsMy Sql concepts
My Sql concepts
 
Oops
OopsOops
Oops
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
70433 Dumps DB
70433 Dumps DB70433 Dumps DB
70433 Dumps DB
 
70 433
70 43370 433
70 433
 
70562-Dumps
70562-Dumps70562-Dumps
70562-Dumps
 
70562 (1)
70562 (1)70562 (1)
70562 (1)
 
32916
3291632916
32916
 
Mobile testingartifacts
Mobile testingartifactsMobile testingartifacts
Mobile testingartifacts
 
GL_Web application testing using selenium
GL_Web application testing using seleniumGL_Web application testing using selenium
GL_Web application testing using selenium
 
Gl qtp day 3 1
Gl qtp day 3   1Gl qtp day 3   1
Gl qtp day 3 1
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 

70 562

  • 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 for reference 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. The database table has a column named LineTotal. You need to ensure that when the size of the LineTotal column value is greater than seven characters, the column 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. 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. } 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: A 2. 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 for reference 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") %>' /> | English | Chinese | Japan | Korean | -4- Test Information Co., Ltd. All rights reserved.
  • 4. 12 </td> 13 </ItemTemplate> The SqlDataSource1 object retrieves the data from a Microsoft SQL Server 2005 database table. The database table has a column named LineTotal. You need to ensure that when the size of the LineTotal column value is greater than seven characters, the column 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 If End Sub B. 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. Else LineTotal.ForeColor = Color.Black End If End Sub C. 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 If End Sub D. 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 If End Sub Answer: A | English | Chinese | Japan | Korean | -6- Test Information Co., Ltd. All rights reserved.
  • 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 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: B | English | Chinese | Japan | Korean | -7- Test Information Co., Ltd. All rights reserved.
  • 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 named Products. You write the following code segment to create the rptData_ItemDataBound event handler. (Line numbers are included for reference only.) 01 Protected Sub rptData_ItemDataBound(ByVal sender As Object, _ 02 ByVal e As RepeaterItemEventArgs) 03 04 If lbl IsNot Nothing Then 05 If Integer.Parse(lbl.Text) < 10 Then 06 lbl.ForeColor = Color.Red 07 End If 08 End If 09 End Sub You 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. 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: B 5. 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 create a 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 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); | English | Chinese | Japan | Korean | -9- Test Information Co., Ltd. All rights reserved.
  • 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: D 6. 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 create a 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. 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: D 7. 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 to the 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. 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. C. protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); LoadControls(); } D. protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); LoadControls(); } Answer: D 8. 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 to the 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. PlHolder.Controls.Add(c) End If End Sub Protected Sub Chk_CheckedChanged(ByVal sender As Object, _ ByVal e As EventArgs) ViewState("CtrlA") = Chk.Checked PlHolder.Controls.Clear() LoadControls() End Sub 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 Overloads Overrides Function _ SaveViewState() As Object LoadControls() Return MyBase.SaveViewState() End Function B. Protected Overloads Overrides _ Sub Render(ByVal writer As HtmlTextWriter) LoadControls() MyBase.Render(writer) End Sub C. Protected Overloads Overrides Sub _ OnLoadComplete(ByVal e As EventArgs) MyBase.OnLoadComplete(e) LoadControls() End Sub D. Protected Overloads Overrides Sub _ | English | Chinese | Japan | Korean | - 14 - Test Information Co., Ltd. All rights reserved.
  • 14. LoadViewState(ByVal savedState As Object) MyBase.LoadViewState(savedState) LoadControls() End Sub Answer: D 9. 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 the MyControl class. (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. 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. Answer: B 10. 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 the MyControl class. (Line numbers are included for reference only.) 01 Protected Overloads Overrides Sub CreateChildControls() 02 Controls.Clear() 03 Dim oFData As New OrderFormData("OrderForm") 04 05 End Sub You 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: B 11. 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. 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: A 12. 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. Which code segment should you use? A. Protected Overloads Overrides Sub _ CreateChildControls() Controls.Clear() Dim oFData As New OrderFormData("OrderForm") Controls.Add(oFData) End Sub B. Protected Overloads Overrides Sub _ RenderContents(ByVal writer As HtmlTextWriter) Dim oFData As New OrderFormData("OrderForm") oFData.RenderControl(writer) End Sub C. Protected Overloads Overrides Sub _ EnsureChildControls() Controls.Clear() Dim oFData As New OrderFormData("OrderForm") oFData.EnsureChildControls() If Not ChildControlsCreated Then CreateChildControls() End If End Sub D. Protected Overloads Overrides Function _ CreateControlCollection() As ControlCollection Dim controls As New ControlCollection(Me) Dim oFData As New OrderFormData("OrderForm") controls.Add(oFData) Return controls End Function Answer: A | English | Chinese | Japan | Korean | - 18 - Test Information Co., Ltd. All rights reserved.
  • 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 void CheckOrderFormEventHandler(EventArgs e); private static readonly object CheckOrderFormKey = 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 = | English | Chinese | Japan | Korean | - 19 - Test Information Co., Ltd. All rights reserved.
  • 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: B 14. 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 CheckOrderFormEventHandler Public 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. RemoveHandler(ByVal value As CheckOrderFormEventHandler) Events.[RemoveHandler](CheckOrderFormKey, value) End RemoveHandler RaiseEvent(ByVal e As EventArgs) End RaiseEvent End Event You 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 Sub B. Protected Overridable Sub _ OnCheckOrderForm(ByVal e As EventArgs) Dim checkOrderForm As CheckOrderFormEventHandler = _ TryCast(Events(CheckOrderFormKey), _ CheckOrderFormEventHandler) RaiseEvent CheckOrderForm(e) End Sub C. 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. End If End Sub D. Private checkOrderForm As New _ CheckOrderFormEventHandler(AddressOf _ checkOrderFormCallBack) Protected Overridable Sub _ OnCheckOrderForm(ByVal e As EventArgs) If checkOrderForm IsNot Nothing Then RaiseBubbleEvent(checkOrderForm, e) End If End Sub Answer: B 15. 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. 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: B 16. 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. 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 < 10 End Sub 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" 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. 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: B 17. 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. } 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 18. 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 Function You 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. Return isValid End Function B. Protected Overloads Overrides _ Function ControlPropertiesValid() As Boolean Dim value As String = _ GetControlValidationValue(Me.ValidationGroup) Dim isValid As Boolean = Validate(value) Return isValid End Function C. Protected Overloads Overrides Function EvaluateIsValid() As Boolean Dim value As String = _ GetControlValidationValue(Me.ControlToValidate) Dim isValid As Boolean = Validate(value) Return isValid End Function D. 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 True End Function Answer: C 19. 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 bound to 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. <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 to XmlDataSource1. 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. DataTextField="ID" DataValueField="Name" onclick="BulletedList1_Click"> </asp:BulletedList> Answer: C 20. 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 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 Sub BulletedList1_Click(ByVal sender As _ ?Object, ByVal e As BulletedListEventArgs) '... End Sub You need to add a BulletedList control named BulletedList1 to the Web page that is bound to XmlDataSource1. 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. 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: C 21. 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 the ListBox1 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. 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. ListBox1.Items.Remove(li); } Answer: C 22. 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 the ListBox1 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 If Next B. For Each li As ListItem In ListBox1.Items If li.Selected Then li.Selected = False ListBox2.Items.Add(li) ListBox1.Items.Remove(li) End If Next | English | Chinese | Japan | Korean | - 32 - Test Information Co., Ltd. All rights reserved.
  • 32. C. For Each li As ListItem In ListBox1.Items If li.Selected Then li.Selected = False ListBox2.Items.Add(li) End If Next D. For Each li As ListItem In ListBox2.Items If ListBox1.Items.Contains(li) Then ListBox1.Items.Remove(li) End If Next E. For Each li As ListItem In ListBox1.Items If li.Selected Then li.Selected = False ListBox2.Items.Add(li) End If Next F. For Each li As ListItem In ListBox1.Items If ListBox2.Items.Contains(li) Then ListBox1.Items.Remove(li) End If Next Answer: C 23. 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. ?"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 View controls. 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: A 24. 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. </asp:DropDownList> You also add a MultiView control named MultiView1 to the Web page. MultiView1 has three child View controls. You need to ensure that you can select the View controls by using the DropDownList1 DropDownList control. Which code segment should you use? A. Dim idx As Integer = DropDownList1.SelectedIndex MultiView1.ActiveViewIndex = idx B. Dim idx As Integer = DropDownList1.SelectedIndex MultiView1.Views(idx).Visible = True C. Dim idx As Integer = Integer.Parse(DropDownList1.SelectedValue) MultiView1.ActiveViewIndex = idx D. Dim idx As Integer = Integer.Parse(DropDownList1.SelectedValue) MultiView1.Views(idx).Visible = True Answer: A 25. 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. 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: A 26. 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. <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 = False End If B. 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 If End If C. 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 If Next For Each dt As DateTime In list TryCast(sender, Calendar).SelectedDates.Remove(dt) Next D. 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. If st.DayOfWeek = DayOfWeek.Saturday OrElse _ st.DayOfWeek = DayOfWeek.Sunday Then list.Add(st) End If Next For Each dt As DateTime In list TryCast(sender, Calendar).SelectedDates.Remove(dt) Next Answer: A 27. 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. 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: C 28. 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 Property End Class 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. Dim dt As New DataTable() | English | Chinese | Japan | Korean | - 39 - Test Information Co., Ltd. All rights reserved.
  • 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: C 29. 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 are included 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. 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: C 30. 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. </asp:ObjectDataSource> You write the following code segment for the GetData method of the DAL class. (Line numbers are included for reference only.) 01 Public Function GetData() As Object 02 Dim cnn As New SqlConnection( - 03 Dim strQuery As String = "SELECT * FROM Products" 04 05 End Function 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. 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 ds D. 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: C 31. 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. 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 provide 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. D. SqlDataAdapter da = new SqlDataAdapter(prodCmd); DataSet ds = new DataSet(); da.Fill(ds); return ds; Answer: D 32. 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 only.) 01 Public Function GetCachedProducts( _ ByVal conn As SqlConnection) As Object 02 03 If Cache("products") Is Nothing Then 04 Dim cmd As New SqlCommand("SELECT * FROM Products", conn) 05 conn.Open() 06 Cache.Insert("products", GetData(cmd)) 07 conn.Close() 08 End If 09 Return Cache("products") 10 End Function 11 12 Public Function GetData(ByVal prodCmd As SqlCommand) As Object 13 14 End Function Each time a Web form has to access a list of products, the GetCachedProducts method is called to provide 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. Dim dr As SqlDataReader prodCmd.CommandTimeout = Integer.MaxValue B. dr = prodCmd.ExecuteReader() Return dr C. Dim da As New SqlDataAdapter() da.SelectCommand = prodCmd Dim ds As New DataSet() Return ds.Tables(0) D. Dim da As New SqlDataAdapter(prodCmd) Dim ds As New DataSet() da.Fill(ds) Return ds Answer: D 33. 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 are included 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 contained 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. 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: D 34. 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 are included 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. 05 06 rdr.Close() 07 cnn.Close() You need to ensure that the gvProducts and gvCategories GridView controls display the data that is contained in the following two database tables: ¡¤The Products database tabl ¡¤The Categories database tabl Which 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: D 35. 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. 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 GridView 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. 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: B 36. 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 reference only.) 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. 06 gridCities.DataSource = objDS 07 gridCities.DataBind() 08 Session("ds") = objDS 09 End Sub 10 Protected Sub btnSearch_Click(ByVal sender As Object, _ 11 ByVal e As EventArgs) 12 13 End Sub You need to ensure that when the btnSearch Button control is clicked, the records in the gridCities GridView 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).DefaultView dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'" gridCities.DataSource = dv gridCities.DataBind() Dim ds As DataSet = TryCast(Session("ds"), DataSet) Dim dv As DataView = ds.Tables(0).DefaultView dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'" gridCities.DataSource = dv gridCities.DataBind() Dim dt As DataTable = TryCast(Session("ds"), DataTable) Dim dv As DataView = dt.DefaultView dv.RowFilter = "CityName LIKE '" + txtSearch.Text + "%'" gridCities.DataSource = dv gridCities.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. ?dt.[Select]("CityName LIKE '" + txtSearch.Text + "%'") gridCities.DataSource = rows gridCities.DataBind() Answer: B 37. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The application 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. 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: A 38. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The application consumes a Microsoft Windows Communication Foundation (WCF) service. The WCF service exposes the following method. <WebInvoke()> _ Function UpdateCustomerDetails(ByVal custID As String) As String The 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. 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: A 39. 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 following 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 Web 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. 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: A 40. 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 following service contract. (Line numbers are included for reference only.) 01 <ServiceContract()> _ 02 Public Interface IBlogService 03 <OperationContract()> _ 04 <WebGet(ResponseFormat := WebMessageFormat.Xml)> _ 05 Function GetBlog() As Rss20FeedFormatter 06 End Interface You 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. You need to store the result of the GetBlog operation in an XmlDocument variable named xmlBlog in a Web 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: A 41. 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. 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. pm.DefaultValue = DateTime.Now; return pm; } Answer: C 42. 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 Parameter End Class 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 Sub New() MyBase.New("Value", TypeCode.DateTime, DateTime.Now.ToString()) End Sub B. Protected Overloads Overrides Sub _ LoadViewState(ByVal savedState As Object) DirectCast(savedState, _ | English | Chinese | Japan | Korean | - 57 - Test Information Co., Ltd. All rights reserved.
  • 57. StateBag).Add("Value", DateTime.Now) End Sub C. Protected Overloads Overrides Function _ Evaluate(ByVal context As HttpContext, _ ByVal control As Control) As Object Return DateTime.Now End Function D. Protected Overloads Overrides Function _ Clone() As Parameter Dim pm As Parameter = New DayParameter() pm.DefaultValue = DateTime.Now Return pm End Function Answer: C 43. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The application 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. 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: AC 44. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. The application 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 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. Public Sub Application_Error(ByVal sender As Object, _ ByVal e As EventArgs) Dim exc As Exception = Server.GetLastError() 'Write Exception details to event log End Sub | English | Chinese | Japan | Korean | - 59 - Test Information Co., Ltd. All rights reserved.
  • 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 Sub Answer: AC 45. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. 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 to remote users. You need to ensure that the OrderError.htm Web page is displayed for unhandled errors only in the OrderDetails.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. 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: C 46. You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. 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 to remote users. You need to ensure that the OrderError.htm Web page is displayed for unhandled errors only in the OrderDetails.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. 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: C 47. 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. </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 is asynchronously 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. Label3.Text = "Label3 updated value"; } Answer: B 48. 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 is asynchronously 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 Sub B. 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. Label2.Text = "Label2 updated value" ScriptManager1.RegisterDataItem(Label3, _ "Label3 updated value") End Sub C. 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 Sub D. 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 Sub Answer: B 49. 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 are included 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. 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 btnSubmit 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. 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. request.completed(new Sys.CancelEventArgs()); alert('A previous request is still in progress.'); } } </script> Answer: C 50. 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 are included 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 Sub 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> | English | Chinese | Japan | Korean | - 68 - Test Information Co., Ltd. All rights reserved.
  • 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 the btnSubmit 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.
  • 69. 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: C 51. You 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; | English | Chinese | Japan | Korean | - 70 - Test Information Co., Ltd. All rights reserved.
  • 70. } return a/b; } 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 the JavaScript 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 the resource 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: C 52. You 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; | English | Chinese | Japan | Korean | - 71 - Test Information Co., Ltd. All rights reserved.
  • 71. } return a/b; } 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 the JavaScript 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 the resource file. Which code segment should you add in the AssemblyInfo.vb 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: C 53. You 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" /> | English | Chinese | Japan | Korean | - 72 - Test Information Co., Ltd. All rights reserved.