PrepAway - Latest Free Exam Questions & Answers

Author: admin

Which code segment should you use?

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>
</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?

Which code segment should you use?

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?

Which code fragment should you use?

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(sender As Object, 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?

Which code fragment should you add to the Web page?

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 ServerValidate(source As Object, args As ServerValidateEventArgs)
Dim dt As DateTime = [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?

Which code segment should you insert at line 04?

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

Which method should you add to the Web page?

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"
PlHolder.Controls.Add(c)
End If

End Sub

Protected Sub Chk_CheckedChanged(sender As Object, 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?

Which code segment should you insert at line 02?

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(sender As Object, e As RepeaterItemEventArgs)
02
03 If lbl IsNot Nothing Then
04 If Integer.Parse(lbl.Text) < 10 Then
05 lbl.ForeColor = Color.Red
06 End If
07 End If
08 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 02?

Which code segment should you use?

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
Return m_Price
End Get
Set
m_Price = Value
End Set
End Property
Private m_Price As Decimal
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?

Which override method should you use?

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 Shared Function Validate(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?