PrepAway - Latest Free Exam Questions & Answers

Author: admin

Which line of code should you insert in the constructor of the page?

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

You write the following code segment in the code-behind file for the page.

Private Sub BindData(sender As Object, e As EventArgs)
lstLanguages.DataSource = CultureInfo.GetCultures(CultureTypes.AllCultures)
lstLanguages.DataTextField = "EnglishName"
lstLanguages.DataBind()
End Sub

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

Which code segment should you insert in the constructor of the page?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a page that contains the following control.
<asp:Calendar EnableViewState="false"ID="calBegin" runat="server" />
You write the following code segment in the code-behind file for the page.

Private Sub LoadDate(sender As Object, e As EventArgs)
If IsPostBack Then
calBegin.SelectedDate = DirectCast(ViewState("date"), DateTime)
End If
End Sub
Private Sub SaveDate(sender As Object, e As EventArgs)
ViewState("date") = calBegin.SelectedDate
End Sub

You need to ensure that the calBegin Calendar control maintains the selected date.
Which code segment should you insert in the constructor of the page?

Which code segment should you insert at line 13?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web page that has a GridView control named GridView1. The GridView1 control displays the data from a database named Region and a table named Location.
You write the following code segment to populate the GridView1 control. (Line numbers are included for reference only.)

01Protected Sub Page_Load(sender As Object, e As EventArgs)
02 Dim connstr As String
03
04 SqlDependency.Start(connstr)
05 Using connection As New SqlConnection(connstr)
06 Dim sqlcmd As New SqlCommand()
07 Dim expires As DateTime = DateTime.Now.AddMinutes(30)
08 Dim dependency As New SqlCacheDependency("Region", "Location")
09 Response.Cache.SetExpires(expires)
10 Response.Cache.SetValidUntilExpires(True)
11 Response.AddCacheDependency(dependency)
12 sqlcmd.Connection = connection
13
14 GridView1.DataSource = sqlcmd.ExecuteReader()
15 GridView1.DataBind()
16 End Using
17 End Sub

You need to ensure that the proxy servers can cache the content of the GridView1 control.
Which code segment should you insert at line 13?

Which code segment should you insert at line 03?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a custom Web user control named SharedControl. The control will be compiled as a library.
You write the following code segment for the SharedControl control. (Line numbers are included for reference only.)

01 Protected Overrides Sub OnInit(e As EventArgs)
02 MyBase.OnInit(e)
03
04 End Sub

All the master pages in the ASP.NET application contain the following directive.
<%@ Master Language="C#" EnableViewState="false" %>
You need to ensure that the state of the SharedControl control can persist on the pages that reference a master page.
Which code segment should you insert at line 03?

Which code segment should you use?

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

Which code segment should you insert at line 03?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
The application allows users to post comments to a page that can be viewed by other users.
You add a SqlDataSource control named SqlDS
1. You write the following code segment. (Line numbers are included for reference only.)

01 Private Sub SaveComment()
02 Dim ipaddr As String
03
04 SqlDS1.InsertParameters("IPAddress").DefaultValue = ipaddr
05 ‘…
06 SqlDS1.Insert()
07 End Sub

You need to ensure that the IP Address of each user who posts a comment is captured along with the user’s comment.
Which code segment should you insert at line 03?

Which code segment should you write?

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

Which code segment should you use?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
The application contains the following code segment.

Public Class CapabilityEvaluator

Public Shared Function ChkScreenSize(cap As System.Web.Mobile.MobileCapabilities, arg As [String]) As Boolean
Dim screenSize As Integer = cap.ScreenCharactersWidth * cap.ScreenCharactersHeight
Return screenSize < Integer.Parse(arg)
End Function

End Class

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

Which code segment should you insert at line 05?

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" />
<asp:Button runat="server" ID="btnSubmit" Text="Submit" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="updSecondPanel" UpdateMode="Conditional">
<ContentTemplate> …
</ContentTemplate>
</asp:UpdatePanel>
When the updFirstPanel UpdatePanel control is updated, a dynamic client script is registered.
You write the following code segment in the code-behind file of the Web form. (Line numbers are included for reference only.)

01 Protected Sub Page_Load(sender As Object, e As EventArgs)
02 If IsPostBack Then
03
04 Dim generatedScript As String = ScriptGenerator.GenerateScript()
05
06 End If
07 End Sub

You need to ensure that the client-script code is registered only when an asynchronous postback is issued on the updFirstPanel UpdatePanel control.
Which code segment should you insert at line 05?

Which code segment should you add in the AssemblyInfo.cs file?

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;
}

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?