70562-Dumps
Upcoming SlideShare
Loading in...5
×
 

70562-Dumps

on

  • 1,940 views

 

Statistics

Views

Total Views
1,940
Views on SlideShare
1,940
Embed Views
0

Actions

Likes
1
Downloads
21
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

70562-Dumps 70562-Dumps Document Transcript

  • Microsoft (70-562)TS: Microsoft .NET Framework 3.5ASP.NET Application Development (VB)Questions and answers along with explanations
  • Question 1You 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 aredescribed 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: <sessionState mode="InProc" stateConnectionString="tcpip=192.168.10.20:443" timeout="10" />B) Add the following element to Web.config: <sessionState mode="StateServer" stateConnectionString="tcpip=192.168.10.20:42424" timeout="10" />C) Add the following element to Web.config: <sessionState mode="StateServer" stateConnectionString="tcpip=192.168.10.20:443" stateNetworkTimeout="10" />D) Add the following element to Web.config: <sessionState mode="SqlServer" sqlConnectionString="data source=192.168.10.20;Integrated Security=SSPI" sqlConnectionTimeout="10" />
  • Answer BYou should add the following element to Web.config:<sessionState mode="StateServer"stateConnectionString="tcpip=192.168.10.20:42424"timeout="10" />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 setthe mode attribute to StateServer and specify a stateConnectionString that identifies theserver running state service. State service always listens on port 42424. You set thetimeout attribute to the number of minutes a session can be idle before it should bedisconnected.You should not add the following element to Web.config:<sessionState mode="InProc"stateConnectionString="tcpip=192.168.10.20:443"timeout="10" />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:<sessionState mode="SqlServer"sqlConnectionString="data source=192.168.10.20;Integrated Security=SSPI"sqlConnectionTimeout="10" />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:<sessionState mode="StateServer"stateConnectionString="tcpip=192.168.10.20:443"stateNetworkTimeout="10" />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. View slide
  • Question 2You create a custom control for a Microsoft ASP.NET 3.5 Web application. The control isimplemented as follows:Public Class CircleInherits ControlPublic Property Radius() As DoubleGetDim radius As Object = ViewState("Radius")If radius Is Nothing Thenradius = 0.0End IfReturn CType(radius, Double)End GetSet (ByVal Value As Double)ViewState("Radius") = valueEnd SetEnd PropertyEnd ClassYou 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 ScriptMethod attribute to the method.C) Derive the class from ScriptControlDescriptor instead of Control.D) Apply the ScriptService attribute to the class. View slide
  • Answer AYou should implement the IScriptControl interface. This interface defines two methodsnamed GetScriptDescriptors and GetScriptReferences. The GetScriptDescriptors methodreturns a collection of ScriptDescriptor instances that represent client components. TheGetScriptReferences method returns a collection of ScriptReference instances that representembedded 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. Thisattribute 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.
  • Question 3You are creating a Web application that calls a service that is defined as shown in theexhibit.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 Double result = channel.Average(values)B) Dim addr As EndpointAddress = New EndpointAddress("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)C) Dim addr As EndpointAddress = New EndpointAddress("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)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)
  • Answer BYou 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 Doubleresult = channel.Average(values)The ChannelFactory class is a generic class. You must identify the contracts type when youinstantiate the class. Also, you must specify a binding or an endpoint when instantiatingChannelFactory. 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 contracts type when youinstantiate the class.
  • Question 4You create a Web application by using Microsoft ASP.NET 3.5. You add a ScriptManagercontrol 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 SubYou 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, youcannot 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 anasynchronous 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.
  • Answer AYou 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 pageoutput 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. Afteran 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 notimplement 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.
  • Question 5You are creating a Web site using ASP.NET 3.5. You want the list of products on a Webpage 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 anyother reason.What code should you use?A) <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:GridView ID="grdProducts" runat="server"> </asp:GridView> </ContentTemplate> </asp:UpdatePanel>B) <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always"> <ContentTemplate> <asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:GridView ID="grdProducts" runat="server"> </asp:GridView> </ContentTemplate> </asp:UpdatePanel>C) <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" > <ContentTemplate> <asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:GridView ID="grdProducts" runat="server"> </asp:GridView> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlCategories" EventName="SelectedIndexChanged" /> <asp:AsyncPostBackTrigger ControlID="ddlPriceRange" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel>D) <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Always"> <ContentTemplate> <asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"> </asp:DropDownList> <asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True">
  • </asp:DropDownList><asp:GridView ID="grdProducts" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="ddlCategories"EventName="SelectedIndexChanged" /><asp:AsyncPostBackTrigger ControlID="ddlPriceRange"EventName="SelectedIndexChanged" /></Triggers></asp:UpdatePanel>
  • Answer AYou should use the following code:<asp:ScriptManager ID="ScriptManager1" runat="server" /><asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true"UpdateMode="Conditional"><ContentTemplate><asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"></asp:DropDownList><asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"></asp:DropDownList><asp:GridView ID="grdProducts" runat="server"></asp:GridView></ContentTemplate></asp:UpdatePanel>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 ChildrenAsTriggersattribute to True.You should not use the following code:<asp:ScriptManager ID="ScriptManager1" runat="server" /><asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false"UpdateMode="Always"><ContentTemplate><asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"></asp:DropDownList><asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"></asp:DropDownList><asp:GridView ID="grdProducts" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="ddlCategories"EventName="SelectedIndexChanged" /><asp:AsyncPostBackTrigger ControlID="ddlPriceRange"EventName="SelectedIndexChanged" /></Triggers></asp:UpdatePanel>Or<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/><asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" ><ContentTemplate><asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"></asp:DropDownList><asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"></asp:DropDownList><asp:GridView ID="grdProducts" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="ddlCategories"
  • EventName="SelectedIndexChanged" /><asp:AsyncPostBackTrigger ControlID="ddlPriceRange"EventName="SelectedIndexChanged" /></Triggers></asp:UpdatePanel>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:<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/><asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true"UpdateMode="Always"><ContentTemplate><asp:DropDownList ID="ddlCategories" runat="server" AutoPostBack="True"></asp:DropDownList><asp:DropDownList ID="ddlPriceRanges" runat="server" AutoPostBack="True"></asp:DropDownList><asp:GridView ID="grdProducts" runat="server"></asp:GridView></ContentTemplate></asp:UpdatePanel>If you set UpdateMode to Always, the UpdatePanel will be refreshed if a postback occurs forany reason.
  • Question 6You are creating a Web application that will be accessed by mobile devices. You want todisplay a different graphic in an Image control depending on the screen resolution,preferred image type, and whether the mobile device supports color.You plan to use the device-specific choice element and custom filters. A portion of theChoice 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 As System.Web.Mobile.MobileCapabilities, ByVal arg As String) As Boolean Code to check capabilities End FunctionB) Public Sub colorHighResJPG(ByVal capabilities As System.Web.Mobile.Device, ByRef applyFilter As Boolean) Code to check capabilities End FunctionC) Public Function colorHighResJPG(ByVal capabilities As System.Web.Mobile.MobileCapabilities) As String Code to check capabilities End FunctionD) Public Function colorHighResJPG(ByVal capabilities As System.Web.Mobile.BrowserCapabilities) As Boolean Code to check capabilities End Function
  • Answer AYou should use the following code:Public Function colorHighResJPG(ByVal capabilities AsSystem.Web.Mobile.MobileCapabilities, ByVal arg As String) As BooleanCode to check capabilitiesEnd FunctionThe 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 AsSystem.Web.Mobile.BrowserCapabilities) As BooleanCode to check capabilitiesEnd FunctionThe 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 AsSystem.Web.Mobile.MobileCapabilities) As StringCode to check capabilitiesEnd FunctionThe 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 FunctionYou 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.
  • Question 7You are creating a Web application using ASP.NET 3.5.You want requests to videos.aspx to asynchronously load playvideo.aspx and display thevideo 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)
  • Answer DYou should use the following code:Server.TransferRequest("playvideo.aspx", True)The TransferRequest method of the Server object causes the page specified to be loadedasynchronously. 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. PassingTrue 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 specifiedpage. 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 thephysical location of the virtual directory on the Web server. Also, there is no version of theMapPath method that has two parameters.
  • Question 8You are using Visual Studio 2008 to modify a Web application that was created using VisualStudio 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.
  • Answer CYou 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 isonly 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 WebReference 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 configuredwith an earlier target framework that does not include the System.ServiceModel.Webcomponent.
  • Question 9You create a Web application by using Microsoft ASP.NET 3.5. The following markup existson a page:<asp:Wizard ID="_wizard" runat="server" ActiveStepIndex="0"OnNextButtonClick="OnNext"><WizardSteps><asp:WizardStep ID="_welcomeStep" runat="server" Title="Welcome">This wizard helps you create a survey.</asp:WizardStep><asp:WizardStep ID="_chooseQuestionsStep" runat="server" Title="Choose YourQuestions"><asp:GridView ID="_questionsGridView" runat="server"/><asp:CheckBox ID="_checkBox" Checked="True" runat=server Text="Create Questions"/></asp:WizardStep><asp:WizardStep ID="_createQuestionsStep" runat="server" Title="Create YourQuestions"><cc:QuestionEditor ID="_question" runat="server"/><br><asp:Button ID="_addQuestion" runat="server"/></asp:WizardStep><asp:WizardStep ID="_finishStep" runat="server" Title="Done"></asp:WizardStep></WizardSteps></asp:Wizard>You need to implement the OnNext event handler so that the third step (Create YourQuestions) 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 = True End If End SubB) 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 = True End If End SubC) 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 If End SubD) Protected Sub OnNext(ByVal sender As Object, _ ByVal e As WizardNavigationEventArgs) If e.CurrentStepIndex = _wizard.WizardSteps.IndexOf(_chooseQuestionsStep) AndAlso _checkBox.Checked Then e.Cancel = False End If End Sub
  • Answer CYou 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 WizardNavigationEventArgsparameter that specifies the current step and the next defined step, as indicated by theCurrentStepIndex 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.
  • Question 10You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in theApp_Code folder:Public Class ObjectParameterInherits ParameterPrivate _objectTypeName As StringPrivate _propertyName As StringPublic Property ObjectTypeName() As StringGetReturn _objectTypeNameEnd GetSet_objectTypeName = valueEnd SetEnd PropertyPublic Property PropertyName() As StringGetReturn _propertyNameEnd GetSet_propertyName = valueEnd SetEnd PropertyProtected Overrides Function Evaluate(ByVal context As HttpContext, _ByVal control As Control) As ObjectIf String.IsNullOrEmpty(ObjectTypeName) ThenThrow New InvalidOperationException("ObjectTypeName is not set")End IfIf String.IsNullOrEmpty(PropertyName) ThenThrow New InvalidOperationException("PropertyName is not set")End IfDim 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 ClassPublic Class SecurityPublic Shared ReadOnly Property UserID() As StringGetReturn Session("UserID")End GetEnd PropertyEnd ClassThe following stored procedure exists in a Microsoft SQL Server 2008 database:CREATE PROCEDURE GetStoresByUser @UserID INT ASSELECT StoreID, StoreName FROM Store where UserID=@UserID
  • 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) <SqlDataSource ID="_dataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SupplyChain%>" SelectCommand="GetStoresByUser" SelectCommandType="Text"> <SelectParameters> <cust:ObjectParameter Name="Security.UserID"/> </SqlDataSource>B) <ObjectDataSource ID="_dataSource" runat="server" DataObjectTypeName="StoredProcedure" TypeName="ConnectionStrings.SupplyChain" SelectMethod="GetStoresByUser"> <SelectParameters> <cust:ObjectParameter Name="Security.UserID"/> </SelectParameters> </ObjectDataSource>C) <ObjectDataSource ID="_dataSource" runat="server" DataObjectTypeName="<%$ ConnectionStrings:SupplyChain%>" TypeName="StoredProcedure" SelectMethod="GetStoresByUser"> <SelectParameters> <cust:ObjectParameter Name="UserID" ObjectTypeName="Security" PropertyName="UserID"/> </SelectParameters> </ObjectDataSource>D) <SqlDataSource ID="_dataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SupplyChain%>" SelectCommand="GetStoresByUser" SelectCommandType="StoredProcedure"> <SelectParameters> <cust:ObjectParameter Name="UserID" ObjectTypeName="Security" PropertyName="UserID"/> </SelectParameters> </SqlDataSource>
  • Answer DYou should use the following declaration:<SqlDataSource ID="_dataSource" runat="server"ConnectionString="<%$ ConnectionStrings:SupplyChain%>"SelectCommand="GetStoresByUser"SelectCommandType="StoredProcedure"><SelectParameters><cust:ObjectParameterName="UserID"ObjectTypeName="Security"PropertyName="UserID"/></SelectParameters></SqlDataSource>This declares a SqlDataSource control that connects to the database. The SelectCommandproperty specifies the SQL command or stored procedure to execute. In this scenario, theSelectCommandType property is set to StoredProcedure, so the value specified in theSelectCommand 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 tobusiness or data objects. The TypeName property of this control should specify the commonlanguage runtime (CLR) type of the object to query. The SelectMethod property shouldspecify 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 deleteoperation.You should not use the following declaration:<SqlDataSource ID="_dataSource" runat="server"ConnectionString="<%$ ConnectionStrings:SupplyChain%>"SelectCommand="GetStoresByUser"SelectCommandType="Text"><SelectParameters><cust:ObjectParameter Name="Security.UserID"/></SqlDataSource>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 parameterexpected by the stored procedure. Also, in this scenario, if you do not set theObjectTypeName and PropertyName properties, the ObjectParameter class throws anexception.
  • Question 11You create a Web application by using Microsoft ASP.NET 3.5. The following code exists inthe application:Public Class AccountPrivate _balance As DoublePublic Property Balance() As DoubleGetReturn _balanceEnd GetSet_balance = valueEnd SetEnd PropertyPublic Sub Deposit(ByVal amount As Double)Balance = Balance + amountEnd SubPublic Sub Withdraw(ByVal amount As Double)System.Diagnostics.Trace.WriteLineIf(amount > Balance, "Potential Overdraft.")If amount <= Balance ThenBalance = Balance - amountEnd IfEnd SubEnd ClassThis code writes a trace message if there is potential for an overdraft.You need to configure the Web.config file to write the trace message to the trace viewer tool(Trace.axd).Which configurations should you use? (Each correct answer presents part of the solution.Choose two.)A) <trace enabled="true"/>B) <system.diagnostics> <trace> <listeners> <add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </listeners> </trace> </system.diagnostics>C) <system.diagnostics> <switches> <add name="PageOutput" value="Trace.axd"/> </switches> </system.diagnostics>D) <trace enabled="false" writeToDiagnosticsTrace="true"/>E) <trace enabled="false" writeToDiagnosticsTrace="true" pageOutput="false"/>
  • Answer A and BYou should use the following configuration:<system.diagnostics><trace><listeners><add name="WebPageTraceListener"type="System.Web.WebPageTraceListener,System.Web,Version=2.0.3600.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"/></listeners></trace></system.diagnostics>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:<trace enabled="true"/>This configuration enables ASP.NET tracing. If you do not enable ASP.NET tracing, nothingwill be written to the ASP.NET tracing subsystem. Note that you must add this configurationin the <system.web> section.You should not use the following configuration:<trace enabled="false" writeToDiagnosticsTrace="true"/>This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attribute specifieswhether ASP.NET trace messages should be written to listeners defined for diagnostictracing. However, in this scenario, you need to write diagnostic trace messages to theASP.NET tracing subsystem.You should not use the following configuration:<trace enabled="false" writeToDiagnosticsTrace="true" pageOutput="false"/>This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attribute specifieswhether ASP.NET trace messages should be written to listeners defined for diagnostictracing. However, in this scenario, you need to write diagnostic trace messages to theASP.NET tracing subsystem. The pageOutput attribute specifies whether ASP.NET tracemessages can be viewed by requesting pages in addition to Trace.axd.You should not use the following configuration:<system.diagnostics><switches><add name="PageOutput" value="Trace.axd"/></switches></system.diagnostics>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.
  • Question 12You 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 namedProductScripts.js. The control contains resources translated to various languages. Thecontrols 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) <asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" runat="server"> <Scripts> <asp:ScriptReference Assembly="ProductDisplay" Name=" ProductScripts.js" /> </Scripts> </asp:ScriptManager>B) <asp:ClientScriptManager ID="ClientScriptManager1" EnableScriptLocalization="true" runat="server"> <Scripts> <asp:ScriptReference Assembly="ProductDisplay" Name="ProductScripts.js" /> </Scripts> </asp:ScriptManager>C) <asp:ClientScriptManager ID="ClientScriptManager1" EnableScriptGlobalization="true" runat="server"> <Scripts> <asp:ScriptReference Assembly="ProductDisplay" Name="ProductDisplay.ProductScripts.js" /> </Scripts> </asp:ScriptManager>D) <asp:ScriptManager ID="ScriptManager1" EnableScriptLocalization="true" runat="server"> <Scripts> <asp:ScriptReference Assembly="ProductDisplay" Name="ProductDisplay.ProductScripts.js" /> </Scripts> </asp:ScriptManager>
  • Answer DYou should use the following code:<asp:ScriptManager ID="ScriptManager1" EnableScriptLocalization="true"runat="server"><Scripts><asp:ScriptReference Assembly="ProductDisplay" Name="ProductDisplay.ProductScripts.js"/></Scripts></asp:ScriptManager>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<Scripts> block. To cause the control to use the localized resource strings, you need to setEnableScriptLocalization to True.You should not use the code:<asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true"runat="server"><Scripts><asp:ScriptReference Assembly="ProductDisplay" Name=" ProductScripts.js" /></Scripts></asp:ScriptManager>The EnableScriptGlobalization attribute affects whether the control should respect localesettings when displaying currency and date information. It does not affect languageresource usage.You should not use the code:<asp:ClientScriptManager ID="ClientScriptManager1" EnableScriptLocalization="true"runat="server"><Scripts><asp:ScriptReference Assembly="ProductDisplay" Name="ProductScripts.js" /></Scripts></asp:ScriptManager>Or<asp:ClientScriptManager ID="ClientScriptManager1" EnableScriptGlobalization="true"runat="server"><Scripts><asp:ScriptReference Assembly="ProductDisplay" Name="ProductDisplay.ProductScripts.js"/></Scripts></asp:ScriptManager>The ClientScriptManager class is not an ASP.NET control and cannot be used declaratively.It is a class that is used to programmatically add a script at runtime.
  • Question 13You 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 BooleanReturn Request.Headers("GPS") = Boolean.TrueStringEnd FunctionThis method determines whether the browsers 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: <mobile:Panel ID="_panel" runat="server"> <mobile:DeviceSpecific ID="_deviceSpecific" runat="server"> <Choice Filter="IsGpsSupported"> <ContentTemplate> <cc1:Map ID="_map" runat="server"/> </ContentTemplate> </Choice> <Choice> <ContentTemplate> GPS is not supported on this device. </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel>B) Add the following configuration to the Web.config file: <deviceFilters> <filter name="IsGpsSupported" compare="GPS"/> </deviceFilters> Add the following markup to the page: <mobile:Panel ID="_panel" runat="server"> <mobile:DeviceSpecific ID="_deviceSpecific" runat="server"> <Choice Filter="IsGpsSupported:True"> <ContentTemplate> <cc1:Map ID="_map" runat="server"/> </ContentTemplate> </Choice> <Choice> <ContentTemplate> GPS is not supported on this device. </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel>C) Add the following configuration to the Web.config file:
  • <deviceFilters> <filter name="IsGpsSupported" argument="GPS"/> </deviceFilters> Add the following markup to the page: <mobile:Panel ID="_panel" runat="server"> <mobile:DeviceSpecific ID="_deviceSpecific" runat="server"> <Choice Filter="Headers"> <ContentTemplate> <cc1:Map ID="_map" runat="server"/> </ContentTemplate> </Choice> <Choice> <ContentTemplate> GPS is not supported on this device. </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel>D) Add the following markup to the page: <mobile:Panel ID="_panel" runat="server"> <mobile:DeviceSpecific ID="_deviceSpecific" runat="server"> <Choice Filter="GPS"> <ContentTemplate> <cc1:Map ID="_map" runat="server"/> </ContentTemplate> </Choice> <Choice> <ContentTemplate> GPS is not supported on this device. </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel>
  • Answer AYou 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 mustmeet for the content of that Choice element to be rendered. The ASP.NET mobile frameworkfirst 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 browsers device supports GPS.
  • Question 14You are creating a Web site using ASP.NET 3.5.When the user clicks the btnSubmit button on article.aspx, the application needs to displayreview.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.txtArticle If Not IsNothing(txt) Then lblReviewArticle.Text = Server.HtmlEncode(txt) Else lblReviewArticle.Text = "No article submitted" End IfD) 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 IfE) Add the following code to the Page_Load event of review.aspx: Dim txt As TextBox txt = 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
  • Answers A and DYou 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 toaccess 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) ThenlblReviewArticle.Text = Server.HtmlEncode(txt.Text)ElselblReviewArticle.Text = "No article submitted"End IfIf 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 TextBoxtxt = CType(Context.PreviousHandler.FindControl ("txtArticle"), TextBox)If Not IsNothing(txt) ThenlblReviewArticle.Text = Server.HtmlEncode(txt.Text)ElselblReviewArticle.Text = "No article submitted"End IfThe 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 TextBoxtxt = Application.review.txtArticleIf Not IsNothing(txt) ThenlblReviewArticle.Text = Server.HtmlEncode(txt)ElselblReviewArticle.Text = "No article submitted"End IfYou cannot access a page through the Application object. The Application object is used tostore application state, which is accessible from any session.
  • Question 15You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in theApp_Code folder:Namespace BcdTrain.ProvidersPublic class SessionSiteMapProviderInherits SiteMapProvider Members omitted for brevityEnd ClassEnd NamespaceYou need to modify the Web.config file to ensure that SiteMapDataSource controls use theSessionSiteMapProvider class by default.Which configuration should you use?A) <siteMap defaultProvider="SessionSiteMapProvider"> <providers> <add name="SessionSiteMapProvider" type="BcdTrain.Providers.SessionSiteMapProvider, App_Code"> </providers> </siteMap>B) <siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider, App_Code"> </siteMap>C) <siteMap defaultProvider="SessionSiteMapProvider"> <providers> <add name="BcdTrain.Providers.SessionSiteMapProvider" type="SiteMapProvider"> </providers> </siteMap>D) <siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider"> </siteMap>
  • Answer AYou should use the following configuration:<siteMap defaultProvider="SessionSiteMapProvider"><providers><addname="SessionSiteMapProvider"type="BcdTrain.Providers.SessionSiteMapProvider, App_Code"></providers></siteMap>This configuration adds a site map provider named SessionSiteMapProvider that maps to theSessionSiteMapProvider class in the BcdTrain.Providers namespace. The name attributespecifies 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_Codeindicates 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:<siteMap defaultProvider="SessionSiteMapProvider"><providers><addname="BcdTrain.Providers.SessionSiteMapProvider"type="SiteMapProvider"></providers></siteMap>The defaultProvider attribute must match the name of a defined site map provider. Also, thetype attribute must specify the fully-qualified type name of a site map provider.You should not use the following configuration:<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider"></siteMap>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:<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider, App_Code"></siteMap>The defaultProvider attribute must match the name of a defined site map provider. In thisconfiguration, no additional site map providers are defined.