mcts 70562

Upload: rohan-kota

Post on 04-Apr-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 mcts 70562

    1/35

    Microsoft (70-562)

    TS: Microsoft .NET Framework 3.5

    ASP.NET Application Development (VB)Questions and answers along with explanations

  • 7/29/2019 mcts 70562

    2/35

    Question 1

    You have created a Web application using ASP.NET 3.5. The application stores state usingSession state.

    You are planning to deploy the application on a Web farm. The servers in the Web farm are

    described in the exhibit. All servers are configured with a Secure Sockets Layer (SSL)

    certificate.

    A session must be disconnected if it has been idle for more than 10 minutes.

    You need to configure Session state.

    What should you do?

    A) Add the following element to Web.config:

    B) Add the following element to Web.config:

    C) Add the following element to Web.config:

    D) Add the following element to Web.config:

  • 7/29/2019 mcts 70562

    3/35

    Answer B

    You should add the following element to Web.config:

    One way to support Session state on a Web farm is to use the ASP.NET state service. Tospecify that Session state should be stored in the ASP.NET state service, you need to set themode attribute to StateServer and specify a stateConnectionString that identifies the serverrunning state service. State service always listens on port 42424. You set the timeoutattribute to the number of minutes a session can be idle before it should be disconnected.

    You should not add the following element to Web.config:

    When Session state is configured with the mode of InProc, servers on a farm cannot sharesession state. Also, you do not identify a stateConnectionString when the mode is set toInProc because each server stores session state locally.

    You should not add the following element to Web.config:

    You can use SQL Server to store session state on a Web farm. However, thesqlConnectionTimeout identifies the number of seconds to wait for a query to SQL Server,

    not the number of minutes to wait before disconnecting an idle session.

    You should not add the following element to Web.config:

    StateServer always listens on port 42424, not port 443. Also, the stateNetworkTimeout isthe number of seconds to wait for a network transmission between the Web server and theserver running the state service, not the amount of time to wait before disconnecting an idlesession.

  • 7/29/2019 mcts 70562

    4/35

    Question 2

    You create a custom control for a Microsoft ASP.NET 3.5 Web application. The control is

    implemented as follows:

    Public Class CircleInherits Control

    Public Property Radius() As DoubleGetDim radius As Object = ViewState("Radius")If radius Is Nothing Thenradius = 0.0End If

    Return CType(radius, Double)End Get

    Set (ByVal Value As Double)ViewState("Radius") = value

    End SetEnd Property

    End Class

    You need to extend this control so that its Radius property can be set from JavaScript.

    What should you do?

    A) Implement the IScriptControl interface.

    B) Add a method named GetRadius that returns the Radius property, and apply the ScriptMethodattribute to the method.

    C) Derive the class from ScriptControlDescriptor instead of Control.

    D) Apply the ScriptService attribute to the class.

  • 7/29/2019 mcts 70562

    5/35

    Answer A

    You should implement the IScriptControl interface. This interface defines two methodsnamed GetScriptDescriptors and GetScriptReferences. The GetScriptDescriptors method

    returns a collection of ScriptDescriptor instances that represent client components. TheGetScriptReferences method returns a collection of ScriptReference instances that represent

    embedded script resources required by the control.

    You should not apply the ScriptService attribute to the class. This attribute marks a Webservice as one that is accessible from ASP.NET Asynchronous JavaScript and XML (AJAX).This attribute allows the Web service to generate a JavaScript Object Notation (JSON) scriptthat a JavaScript client application can use to call the Web service.

    You should not apply the ScriptMethod attribute to a method named GetRadius. This

    attribute allows you to control the response format of a Web method that is accessible fromASP.NET AJAX.

    You should not derive the class from ScriptControlDescriptor instead of Control. You shouldreturn instances of ScriptControlDescriptor from the GetScriptDescriptors method.ScriptControlDescriptor derives from ScriptDescriptor. ScriptControlDescriptor mapsproperties of a control to client-side properties.

  • 7/29/2019 mcts 70562

    6/35

    Question 3

    You are creating a Web application that calls a service that is defined as shown in the

    exhibit.

    The service is hosted on a Web server at www.stayandsleep.com. The service is namedCalcStatsService.svc.

    You need to create the client code to call the service, passing the argument stored in avariable named values.

    What code should you use?

    A) Dim addr As Uri = New Uri ("http://www.stayandsleep.com/CalcStatsService.svc")Dim binding As New WSHttpBinding()Dim fact As ChannelFactory = New ChannelFactory(binding, addr)Dim channel As ICalcStats= fact.Open()Dim result As Doubleresult = channel.Average(values)

    B) Dim addr As EndpointAddress = NewEndpointAddress("http://www.stayandsleep.com/CalcStatsService.svc")

    Dim binding As New WSHttpBinding()Dim fact As ChannelFactory(Of ICalcStats) = New ChannelFactory(Of ICalcStats)(binding, addr)Dim channel As ICalcStats= fact.CreateChannel()Dim result As Doubleresult = channel.Average(values)

    C) Dim addr As EndpointAddress = NewEndpointAddress("http://www.stayandsleep.com/CalcStatsService.svc")

    Dim fact As ChannelFactory= New ChannelFactory (addr)Dim channel As ICalcStats= fact.CreateChannel()

    Dim result As Doubleresult = channel.Average(values)

    D) Dim addr As Uri = New Uri("http://www.stayandsleep.com/CalcStatsService.svc")Dim binding As New WSHttpBinding()Dim fact As ChannelFactory(Of ICalcStats) = New ChannelFactory(Of ICalcStats)(binding, addr)

    Dim channel As ICalcStats= fact.CreateChannel()Dim result As Double

    result = channel.Average(values)

  • 7/29/2019 mcts 70562

    7/35

    Answer B

    You should use the following code:

    Dim addr As EndpointAddress = NewEndpointAddress("http://www.stayandsleep.com/CalcStatsService.svc")

    Dim binding As New WSHttpBinding()

    Dim fact As ChannelFactory(Of ICalcStats) = New ChannelFactory(Of ICalcStats) (binding,addr)Dim channel As ICalcStats= fact.CreateChannel()Dim result As Doubleresult = channel.Average(values)

    If you want to call a method on a Windows Communication Foundation (WCF) serviceprogrammatically, you must:1. Create an endpoint that references the URL and service name of the service.

    2. Create a binding.3. Instantiate a channel factory using the contract type.

    4. Create a communication channel by calling the CreateChannel method of the factory.

    5. Call the method on the channel.

    You should not use the following code:

    Dim addr As EndpointAddress = NewEndpointAddress("http://www.stayandsleep.com/CalcStatsService.svc")Dim fact As ChannelFactory= New ChannelFactory (addr)

    Dim channel As ICalcStats= fact.CreateChannel()Dim result As Double

    result = channel.Average(values)

    The ChannelFactory class is a generic class. You must identify the contract's type when youinstantiate the class. Also, you must specify a binding or an endpoint when instantiating

    ChannelFactory. If a binding or endpoint has not been added to the Web.config file, youneed to specify the binding and the address of the service.

    You should not use the following code:

    Dim addr As Uri = New Uri("http://www.stayandsleep.com/CalcStatsService.svc")

    Dim binding As New WSHttpBinding()Dim fact As ChannelFactory(Of ICalcStats) = New ChannelFactory(Of ICalcStats) (binding,

    addr)Dim channel As ICalcStats= fact.CreateChannel()Dim result As Doubleresult = channel.Average(values)

    The address must be specified as an EndpointAddress, not as a Uri.

    You should not use the following code:

    Dim addr As Uri = New Uri ("http://www.stayandsleep.com/CalcStatsService.svc")

    Dim binding As New WSHttpBinding()Dim fact As ChannelFactory = New ChannelFactory(binding, addr)Dim channel As ICalcStats= fact.Open()Dim result As Doubleresult = channel.Average(values)

    The address must be specified as an EndpointAddress, not as a Uri. Also, theChannelFactory class is a generic class. You must identify the contract's type when you

    instantiate the class.

  • 7/29/2019 mcts 70562

    8/35

    Question 4

    You create a Web application by using Microsoft ASP.NET 3.5. You add a ScriptManager

    control to a page to enable partial rendering. The following code exists in the code-behindfile of the page:

    Protected Sub Page_Error(ByVal sender As Object, ByVal e As EventArgs)

    Dim ex As Exception = Server.GetLastError()Trace.Warn("Exception", "An unhandled exception has occurred.", ex)End Sub

    You enable ASP.NET tracing for the page. When you visit the page for the first time, you canview the trace message in the page output if an unhandled exception occurs. However, you

    cannot view the trace message in the page output if an unhandled exception occurs duringan asynchronous post back.

    You need to view the trace message when an unhandled exception occurs during an

    asynchronous post back.

    What should you do?

    A) Use the trace viewer tool (Trace.axd) to view the message.

    B) Set the ScriptMode property of the ScriptManager control to Debug.

    C) Add the following code to the end of the Page_Error event handler:Dim script As String = String.Format("Sys.Debug.trace('{0}')", Trace.ToString())

    Page.ClientScript.RegisterStartupScript(Me.ClientID, script)

    D) Set the Debug attribute of the @Page directive to True.

  • 7/29/2019 mcts 70562

    9/35

    Answer A

    You should use Trace.axd to view the message. When asynchronous post backs occur, onlyregions of a page are updated. The entire page is not reloaded. This means that the page

    output generated by the TraceContext class will not be updated during an asynchronouspost back. However, the trace messages still get written to Trace.axd.

    You should not set the ScriptMode property of the ScriptManager control to Debug. Thisproperty determines whether the ScriptManager control should render release or debugversions of Asynchronous JavaScript and XML (AJAX) scripts.

    You should not call the RegisterStartupScript method of the ClientScriptManager class. After

    an asynchronous post back, the script would not be registered on the page because theentire page would not be reloaded. Also, the Sys.Debug.trace AJAX function does not

    implement ASP.NET tracing. It simply writes messages to a TextArea element that has anID of TraceConsole.

    You should not set the Debug attribute of the @Page directive to True. This allows ASP.NETto compile the page with debug symbols. It has no effect on ASP.NET trace messages.

  • 7/29/2019 mcts 70562

    10/35

    Question 5

    You are creating a Web site using ASP.NET 3.5. You want the list of products on a Web

    page to update asynchronously when a product category or a product price range is chosenfrom the drop-down list. The product list should not be modified if a postback occurs for any

    other reason.

    What code should you use?

    A)

    B)

    C)

    D)

  • 7/29/2019 mcts 70562

    11/35

  • 7/29/2019 mcts 70562

    12/35

    Answer A

    You should use the following code:

    An UpdatePanel allows you to group controls for asynchronous updates. When controls areasynchronously updated, only the controls within that panel are updated. The otherelements on the page remain unchanged. You need to define which controls can trigger thepanel to be updated. In this scenario, you need to update the panel when theSelectedIndexChanged event of either ddlCategories or ddlPriceRanges occurs. Becausethese are the only two child controls that initiate a postback, you can meet theserequirements by setting the UpdateMode attribute to Conditional and the ChildrenAsTriggers

    attribute to True.

    You should not use the following code:

    Or

  • 7/29/2019 mcts 70562

    13/35

    EventName="SelectedIndexChanged" />

    You cannot set the UpdateMode to Always and the ChildrenAsTriggers attribute to false.

    Doing so causes an exception. The UpdateMode attribute is set to Always by default. TheEnablePartialRendering attribute is set to true by default.

    You should not use the following code:

    If you set UpdateMode to Always, the UpdatePanel will be refreshed if a postback occurs for

    any reason.

  • 7/29/2019 mcts 70562

    14/35

    Question 6

    You are creating a Web application that will be accessed by mobile devices. You want to

    display a different graphic in an Image control depending on the screen resolution, preferredimage type, and whether the mobile device supports color.

    You plan to use the device-specific choice element and custom filters. A portion of the

    Choice element is shown in the exhibit.

    You need to create the colorHighResJPG filter method.

    What code should you use?

    A) Public Function colorHighResJPG(ByVal capabilities AsSystem.Web.Mobile.MobileCapabilities, ByVal arg As String) As Boolean'Code to check capabilitiesEnd Function

    B) Public Sub colorHighResJPG(ByVal capabilities As System.Web.Mobile.Device, ByRefapplyFilter As Boolean)

    'Code to check capabilitiesEnd Function

    C) Public Function colorHighResJPG(ByVal capabilities AsSystem.Web.Mobile.MobileCapabilities) As String'Code to check capabilitiesEnd Function

    D) Public Function colorHighResJPG(ByVal capabilities As

    System.Web.Mobile.BrowserCapabilities) As Boolean'Code to check capabilities

    End Function

  • 7/29/2019 mcts 70562

    15/35

    Answer A

    You should use the following code:

    Public Function colorHighResJPG(ByVal capabilities AsSystem.Web.Mobile.MobileCapabilities, ByVal arg As String) As Boolean

    'Code to check capabilities

    End Function

    The filter method must accept two arguments: a MobileCapabilities object and a String. Itmust return a Boolean value. If the filter method returns True, that choice will bedisplayed.

    You should not use the following code:

    Public Function colorHighResJPG(ByVal capabilities As

    System.Web.Mobile.BrowserCapabilities) As Boolean'Code to check capabilitiesEnd Function

    The method must accept a MobileCapabilities object as its first argument and a String as itssecond object.

    You should not use the following code:

    Public Function colorHighResJPG(ByVal capabilities As

    System.Web.Mobile.MobileCapabilities) As String'Code to check capabilities

    End Function

    The method must accept a String as its second argument and return a Boolean value.

    You should not use the following code:

    Public Sub colorHighResJPG(ByVal capabilities As System.Web.Mobile.Device, ByRefapplyFilter As Boolean)

    'Code to check capabilitiesEnd Function

    You must create a function that returns a Boolean value, not a Sub that has a Booleanargument passed by reference. Also, the function must accept a MobileCapabilities objectand a String as arguments.

  • 7/29/2019 mcts 70562

    16/35

    Question 7

    You are creating a Web application using ASP.NET 3.5.

    You want requests to videos.aspx to asynchronously load playvideo.aspx and display the

    video that is identified in the query string of videos.aspx.

    You need to program the Page_Load event of videos.aspx to request playvideo.aspx withoutrequiring another request from the browser.

    What code should you use?

    A) Server.TransferRequest("playvideo.aspx", True)

    B) Response.Redirect("playvideo.aspx", True)

    C) Server.MapPath("playvideo.aspx", True)

    D) Server.Transfer("playvideo.aspx", True)

  • 7/29/2019 mcts 70562

    17/35

    Answer D

    You should use the following code:

    Server.TransferRequest("playvideo.aspx", True)

    The TransferRequest method of the Server object causes the page specified to be loaded

    asynchronously. Passing True as the second argument causes QueryString arguments andthe Forms collection to be preserved.

    You should not use the following code:

    Server.Transfer("playvideo.aspx", True)

    The Transfer method causes the page specified to be loaded synchronously. It terminatesloading the current page and initiates the execution of the newly requested URL. Passing

    True as the second argument causes QueryString arguments and the Forms collection to bepreserved.

    You should not use the following code:

    Response.Redirect("playvideo.aspx", True)

    The Redirect method of the Response object causes the browser to request the specified

    page. The second parameter determines whether the current page should terminateexecution.

    You should not use the following code:

    Server.MapPath("playvideo.aspx", True)

    The MapPath method is used to map the virtual path for saving or reading a file to the

    physical location of the virtual directory on the Web server. Also, there is no version of theMapPath method that has two parameters.

  • 7/29/2019 mcts 70562

    18/35

    Question 8

    You are using Visual Studio 2008 to modify a Web application that was created using Visual

    Studio 2005.

    You plan to use classes from the System.ServiceModel.Web namespace. You display the AddReference dialog and notice that the System.ServiceModel.Web component is grayed out.

    You need to reference the component in your application.

    What should you do?

    A) Use mscorcfg.msc to add System.ServiceModel.Web.dll to the global assembly cache

    (GAC).

    B) Display the Add Web Reference dialog box to add a reference.

    C) Display project properties and change the target framework to 3.5.

    D) Use the Browse tab to locate System.ServiceModel.Web.dll.

  • 7/29/2019 mcts 70562

    19/35

    Answer C

    You should display project properties and change the target framework to 3.5. TheSystem.ServiceModel.Web component is a .NET Framework 3.5 component. Therefore, it is

    only available in projects that have a target framework of 3.5 (or higher).

    You should not display the Add Web Reference dialog box to add a reference. The Add Web

    Reference dialog box is used to add a reference to a Web service, not a .NET Frameworkcomponent.

    You should not use the Browse tab to locate System.ServiceModel.Web.dll. TheSystem.ServiceModel.Web component is a .NET Framework component. Therefore, it shouldbe added through the .NET tab.

    You should not use mscorcfg.msc to add System.ServiceModel.Web.dll to the GAC. Thecomponent is already installed in the GAC. It is grayed out because the project is configured

    with an earlier target framework that does not include the System.ServiceModel.Webcomponent.

  • 7/29/2019 mcts 70562

    20/35

    Question 9

    You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists

    on a page:

    This wizard helps you create a survey.


    You need to implement the OnNext event handler so that the third step (Create Your

    Questions) is skipped if the user clears the Create Questions check box option.

    Which code segment should you use?

    A) Protected Sub OnNext(ByVal sender As Object, _ByVal e As WizardNavigationEventArgs)If e.CurrentStepIndex = _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)AndAlso Not _checkBox.Checked Then

    _wizard.MoveTo(_finishStep)Else

    e.Cancel = TrueEnd If

    End Sub

    B) Protected Sub OnNext(ByVal sender As Object, _ByVal e As WizardNavigationEventArgs)If e.CurrentStepIndex = _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)

    AndAlso !_checkBox.Checked Then_wizard.MoveTo(_finishStep)

    e.Cancel = TrueEnd If

    End Sub

    C) Protected Sub OnNext(ByVal sender As Object, _ByVal e As WizardNavigationEventArgs)If e.CurrentStepIndex = _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)

    AndAlso Not _checkBox.Checked Then_wizard.MoveTo(_finishStep)

    End IfEnd Sub

    D) Protected Sub OnNext(ByVal sender As Object, _ByVal e As WizardNavigationEventArgs)

    If e.CurrentStepIndex = _wizard.WizardSteps.IndexOf(_chooseQuestionsStep)AndAlso _checkBox.Checked Thene.Cancel = FalseEnd IfEnd Sub

  • 7/29/2019 mcts 70562

    21/35

    Answer C

    You should implement the event handler to call the MoveTo method of the Wizard class ifthe current step is the Choose Your Questions step and the Checked property of the

    _checkBox control is False. The NextButtonClick event is raised whenever a user clicks theNext button of the Wizard control. This event defines a WizardNavigationEventArgs

    parameter that specifies the current step and the next defined step, as indicated by the

    CurrentStepIndex and NextStepIndex properties of the WizardNavigationEventArgs class.This class also defines a Cancel property that allows you to cancel automatic or manualnavigation. You can perform manual navigation by calling the MoveTo method of the Wizardclass. The MoveTo method changes the ActiveStepIndex property of the Wizard control. Ifthe ActiveStepIndex property is not changed, the Wizard automatically navigates to thenext defined step unless WizardNavigationEventArgs.Cancel is set to True.

    You should not set the Cancel property of the WizardNavigationEventArgs class to True aftercalling the MoveTo method of the Wizard class. This would cancel manual navigation.

    You must call the MoveTo method if the Checked property of the _checkBox control is False.

    Otherwise, the Wizard control will automatically navigate to the next defined step.

    You should not set the Cancel property of the WizardNavigationEventArgs class to True ifthe current step is not the Choose Your Questions step. Because the event handler handlesthe NextButtonClick event for all steps, this would prevent navigation from all other steps.

  • 7/29/2019 mcts 70562

    22/35

    Question 10

    You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in theApp_Code folder:

    Public Class ObjectParameter

    Inherits Parameter

    Private _objectTypeName As StringPrivate _propertyName As String

    Public Property ObjectTypeName() As StringGetReturn _objectTypeName

    End GetSet

    _objectTypeName = valueEnd Set

    End PropertyPublic Property PropertyName() As StringGetReturn _propertyNameEnd GetSet

    _propertyName = valueEnd Set

    End Property

    Protected Overrides Function Evaluate(ByVal context As HttpContext, _ByVal control As Control) As Object

    If String.IsNullOrEmpty(ObjectTypeName) ThenThrow New InvalidOperationException("ObjectTypeName is not set")End If

    If String.IsNullOrEmpty(PropertyName) Then

    Throw New InvalidOperationException("PropertyName is not set")End If

    Dim type As Type = System.Type.GetType(ObjectTypeName)Dim flags As BindingFlags = BindingFlags.Public Or BindingFlags.Static Or _BindingFlags.GetPropertyDim value As Object = type.InvokeMember(flags,Nothing,Nothing,Nothing)

    Return valueEnd FunctionEnd Class

    Public Class Security

    Public Shared ReadOnly Property UserID() As StringGet

    Return Session("UserID")End GetEnd PropertyEnd Class

    The following stored procedure exists in a Microsoft SQL Server 2008 database:

    CREATE PROCEDURE GetStoresByUser @UserID INT AS

    SELECT StoreID, StoreName FROM Store where UserID=@UserID

  • 7/29/2019 mcts 70562

    23/35

    The connection string to the database is stored in the connectionStrings section and has thename SupplyChain.

    You need to use a data source control to call this stored procedure and pass theSecurity.UserID value to it as a parameter.

    Which declaration should you use?

    A)

    B)

    C)

    D)

  • 7/29/2019 mcts 70562

    24/35

    Answer D

    You should use the following declaration:

    This declares a SqlDataSource control that connects to the database. The SelectCommandproperty specifies the SQL command or stored procedure to execute. In this scenario, the

    SelectCommandType property is set to StoredProcedure, so the value specified in the

    SelectCommand property is a stored procedure. The SelectParameters property defines theparameters to pass to the stored procedure. In this scenario, the stored procedure accepts asingle String parameter. To pass the value of Security.UserID as a parameter, you shoulduse the ObjectParameter class and set its properties appropriately. The ObjectTypeNameproperty specifies the name of the class, and the PropertyName property specifies theproperty of that class. In this scenario, the name of the class is Security, and the name ofthe property of that class is UserID.

    You should not use the ObjectDataSource control. This control allows you to bind to

    business or data objects. The TypeName property of this control should specify the commonlanguage runtime (CLR) type of the object to query. The SelectMethod property should

    specify a method of that type that is used to query data. The DataObjectTypeName propertyshould specify a CLR type that can be used for a parameter in an insert, update, or delete

    operation.

    You should not use the following declaration:

    This code sets the SelectCommandType property to Text, which indicates that theSelectCommand property value is a SQL statement. Also, the ObjectParameter propertydoes not set the ObjectTypeName and PropertyName properties, but instead sets the Nameproperty to Security.UserID. You must set the Name property to the name of a parameter

    expected by the stored procedure. Also, in this scenario, if you do not set theObjectTypeName and PropertyName properties, the ObjectParameter class throws an

    exception.

  • 7/29/2019 mcts 70562

    25/35

    Question 11

    You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in

    the application:

    Public Class AccountPrivate _balance As Double

    Public Property Balance() As DoubleGetReturn _balanceEnd GetSet

    _balance = value

    End SetEnd Property

    Public Sub Deposit(ByVal amount As Double)

    Balance = Balance + amountEnd Sub

    Public Sub Withdraw(ByVal amount As Double)System.Diagnostics.Trace.WriteLineIf(amount > Balance, "Potential Overdraft.")If amount

    C)

    D)

    E)

  • 7/29/2019 mcts 70562

    26/35

    Answer A and B

    You should use the following configuration:

    This adds a new trace listener to the Listeners collection of the System.Diagnostics.Traceclass. The WebPageTraceListener class is implemented to write diagnostic trace messages tothe ASP.NET tracing subsystem. Whenever you write a trace message by using theSystem.Diagnostics.Trace class, that message is also written to the ASP.NET tracingsubsystem. You can view messages written to the ASP.NET tracing subsystem by accessingTrace.axd in the current Web application.

    You should also use the following configuration:

    This configuration enables ASP.NET tracing. If you do not enable ASP.NET tracing, nothing

    will be written to the ASP.NET tracing subsystem. Note that you must add this configurationin the section.

    You should not use the following configuration:

    This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attribute specifies

    whether ASP.NET trace messages should be written to listeners defined for diagnostictracing. However, in this scenario, you need to write diagnostic trace messages to the

    ASP.NET tracing subsystem.

    You should not use the following configuration:

    This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attribute specifieswhether ASP.NET trace messages should be written to listeners defined for diagnostic

    tracing. However, in this scenario, you need to write diagnostic trace messages to theASP.NET tracing subsystem. The pageOutput attribute specifies whether ASP.NET trace

    messages can be viewed by requesting pages in addition to Trace.axd.

    You should not use the following configuration:

    This configuration defines a trace switch named PageOutput that is set to the valueTrace.axd. Trace switches allow you to write conditional diagnostic trace messages in anapplication based on the value of the switch.

  • 7/29/2019 mcts 70562

    27/35

    Question 12

    You are creating a Web site using ASP.NET and AJAX.

    The site uses a control that relies on an embedded script stored in a file named

    ProductScripts.js. The control contains resources translated to various languages. Thecontrol's assembly is named ProductDisplay.

    You need to register the script. Your solution must ensure that the control displaysresources in the appropriate language.

    What code should you use?

    A)

    B)

    C)

    D)

  • 7/29/2019 mcts 70562

    28/35

    Answer D

    You should use the following code:

    The ScriptManager control can be used to register scripts that are stored in external files orembedded in an assembly. To load a script that is embedded in an assembly, you need toidentify the assembly and the name of the script in a ScriptReference control inside the

    block. To cause the control to use the localized resource strings, you need to setEnableScriptLocalization to True.

    You should not use the code:

    The EnableScriptGlobalization attribute affects whether the control should respect localesettings when displaying currency and date information. It does not affect language

    resource usage.

    You should not use the code:

    Or

    The ClientScriptManager class is not an ASP.NET control and cannot be used declaratively. Itis a class that is used to programmatically add a script at runtime.

  • 7/29/2019 mcts 70562

    29/35

    Question 13

    You create a mobile Web application by using Microsoft ASP.NET 3.5. The following methodexists in the code-behind file for a page:

    Public Function IsGpsSupported(ByVal capabilities As MobileCapabilities, _

    ByVal optionalArgument As String) As Boolean

    Return Request.Headers("GPS") = Boolean.TrueStringEnd Function

    This method determines whether the browser's device supports global positioning system(GPS).

    You must render a mobile Panel control that meets the following requirements:

    * If the device supports GPS, the Panel control should render a custom control named Map.

    * Otherwise, the Panel control should display the following text: GPS is not supported onthis device.

    You need to declare the mobile Panel control.

    What should you do?

    A) Add the following markup to the page:

    GPS is not supported on this device.

    B) Add the following configuration to the Web.config file:

    Add the following markup to the page:

    GPS is not supported on this device.

    C) Add the following configuration to the Web.config file:

  • 7/29/2019 mcts 70562

    30/35

    Add the following markup to the page:

    GPS is not supported on this device.

    D) Add the following markup to the page:

    GPS is not supported on this device.

  • 7/29/2019 mcts 70562

    31/35

    Answer A

    You should add a DeviceSpecifc control to the Panel control. The DeviceSpecific controlallows you to render different content for different devices. The DeviceSpecific controlsupports one or more Choice elements that define the criteria for rendering to a specificdevice. The Filter attribute of the Choice element specifies the criteria that the device must

    meet for the content of that Choice element to be rendered. The ASP.NET mobile framework

    first attempts to locate a method in the containing page or user control that matches thevalue of the Filter attribute. That method must match a pre-defined signature. The firstparameter must be a MobileCapabilities instance that represents the capabilities of thebrowser. The second parameter must be a String instance that represents an optionalargument. If the mobile framework cannot find such a method, it evaluates the deviceFilterssection of the Web.config file. If it finds a filter element whose name attribute matches theFilter attribute of the Choice element, the mobile framework uses that filter to determinewhether the criteria are met. In this scenario, a method named IsGpsSupported thatmatches the required signature is defined in the code-behind file for the page. Therefore,

    that method will be used to determine whether the criteria are met. If the filter is notpresent, that choice is selected by default.

    You should not specify a value for the Filter attribute of the Choice element that does notmatch either the name of a filter in the Web.config file or the name of a method in thecurrent page. Otherwise, the mobile framework would not be able to evaluate the filter todetermine if the browser's device supports GPS.

  • 7/29/2019 mcts 70562

    32/35

    Question 14

    You are creating a Web site using ASP.NET 3.5.

    When the user clicks the btnSubmit button on article.aspx, the application needs to display

    review.aspx and show the text that the user typed in the TextBox control named txtArticlein a Label control named lblReviewArticle.

    You need to write the code necessary to implement this functionality.

    What should you do? (Each correct answer presents part of the solution. Choose two.)

    A) Add the following code to the btnSubmit_Click event procedure:

    Server.Transfer("review.aspx")

    B) Add the following code to the btnSubmit_Click event procedure:

    Response.Redirect("review.aspx")

    C) Add the following code to the Page_Load event of review.aspx:

    Dim txt As TextBox

    txt = Application.review.txtArticleIf Not IsNothing(txt) Then

    lblReviewArticle.Text = Server.HtmlEncode(txt)Else

    lblReviewArticle.Text = "No article submitted"End If

    D) Add the following code to the Page_Load event of review.aspx:Dim txt As TextBoxtxt = CType(Context.PreviousHandler.FindControl ("txtArticle"), TextBox)

    If Not IsNothing(txt) ThenlblReviewArticle.Text = Server.HtmlEncode(txt.Text)Else

    lblReviewArticle.Text = "No article submitted"End If

    E) Add the following code to the Page_Load event of review.aspx:

    Dim txt As TextBoxtxt = CType(Page.PreviousPage.FindControl ("txtArticle"), TextBox)

    If Not IsNothing(txt) ThenlblReviewArticle.Text = Server.HtmlEncode(txt.Text)

    Else

    lblReviewArticle.Text = "No article submitted"End If

  • 7/29/2019 mcts 70562

    33/35

    Answers A and D

    You should add the following code to the btnSubmit_Click event procedure:

    Server.Transfer("review.aspx")

    You need to perform a cross-page post using Server.Transfer if you want to be able to

    access data from the previous page.

    You should also add the following code to the Page_Load event of review.aspx:

    Dim txt As TextBoxtxt = CType(Page.PreviousPage.FindControl ("txtArticle"), TextBox)If Not IsNothing(txt) Then

    lblReviewArticle.Text = Server.HtmlEncode(txt.Text)Else

    lblReviewArticle.Text = "No article submitted"End If

    If control was transferred to the page using Server.Transfer, you can obtain a reference tothe page that performed the transfer using the PreviousPage property of the Page object.Then you can use the FindControl method to obtain a reference to the control.

    You should not use the following code:

    Add the following code to the btnSubmit_Click event procedure:

    Response.Redirect("review.aspx")

    If you use Response.Redirect, you will not be able to access the previous page. ThePreviousPage property of the Page object will be set to Nothing.

    You should not add the following code to the Page_Load event of review.aspx:

    Dim txt As TextBox

    txt = CType(Context.PreviousHandler.FindControl ("txtArticle"), TextBox)If Not IsNothing(txt) Then

    lblReviewArticle.Text = Server.HtmlEncode(txt.Text)Else

    lblReviewArticle.Text = "No article submitted"End If

    The PreviousHandler property of the Context object returns a reference to the handler thatlast executed. It does not return a reference to the previous page. The HttpHandler objectdoes not have a FindControl method.

    You should not add the following code to the Page_Load event of review.aspx:

    Dim txt As TextBox

    txt = Application.review.txtArticleIf Not IsNothing(txt) ThenlblReviewArticle.Text = Server.HtmlEncode(txt)ElselblReviewArticle.Text = "No article submitted"End If

    You cannot access a page through the Application object. The Application object is used to

    store application state, which is accessible from any session.

  • 7/29/2019 mcts 70562

    34/35

    Question 15

    You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in the

    App_Code folder:

    Namespace BcdTrain.ProvidersPublic class SessionSiteMapProvider

    Inherits SiteMapProvider' Members omitted for brevityEnd ClassEnd Namespace

    You need to modify the Web.config file to ensure that SiteMapDataSource controls use the

    SessionSiteMapProvider class by default.

    Which configuration should you use?

    A)

    B)

    C)

    D)

  • 7/29/2019 mcts 70562

    35/35

    Answer A

    You should use the following configuration:

    This configuration adds a site map provider named SessionSiteMapProvider that maps to theSessionSiteMapProvider class in the BcdTrain.Providers namespace. The name attribute

    specifies a user-friendly name of the provider. The type attribute specifies the fully-qualifiedtype name of the provider in the form [Namespace].[Class], [Assembly]. App_Code

    indicates that the assembly is one that is generated for code in the App_Code folder. Thisconfiguration also sets the defaultProvider attribute to SessionSiteMapProvider, which is thename of the provider that is added. SiteMapDataSource controls that do not specify a valuefor the SiteMapProvider property will automatically use the default provider.

    You should not use the following configuration:

    The defaultProvider attribute must match the name of a defined site map provider. Also, the

    type attribute must specify the fully-qualified type name of a site map provider.

    You should not use the following configuration:

    The defaultProvider attribute must match the name of a defined site map provider. In thisconfiguration, no additional site map providers are defined.

    You should not use the following configuration:

    The defaultProvider attribute must match the name of a defined site map provider. In this

    configuration, no additional site map providers are defined.