October 10, 2013

Asp.net 2012 objective questions answers



Questions


C H A P T E R 1: Introducing ASP.NET 4

Lesson 1: Understanding Web Communications


1. From within an ASP.NET page, you need to run a section of code only if the user has previously loaded the page and is submitting data as part of a form. Which Page object property should you use?
A. IsCallback
B. IsReusable
C. IsValid
D. IsPostBack
2. You are troubleshooting a problem users have when submitting information with a form. The form data does not appear in the web browser’s address bar, but you know the web server is receiving the form data. After capturing the web communications with a sniffer, which type of HTTP request should you examine to see the data the user submitted?
A. PUT
B. CONNECT
C. POST
D. GET

Lesson 2: Creating a Website and Adding New Webpages

1. If you want to create a website on a remote computer running IIS 6.0 that does not have Front Page Server Extensions installed, which website type will you create?
A. Remote HTTP
B. File system
C. FTP
D. Local HTTP

2. Joe created a new website by using Visual Studio 2010, setting the website type to File, and setting the programming language to C#. Later, Joe received an elaborate webpage from his vendor, which consisted of the Vendor.aspx file and the Vendor.aspx.vb code-behind page. What must Joe do to use these files?
A. Joe can simply add the files into the website, because ASP.NET 4 supports websites that have webpages that were programmed with different languages.
B. The Vendor.aspx file will work, but Joe must rewrite the code-behind page by using C#.
C. Both files must be rewritten in C#.
D. Joe must create

Lesson 3: Working with Web Configuration Files

1. You want to make a configuration setting change that will be global to all web and Windows applications on the current computer. Which file do you change?
A. Global.asax
B. Application Web.config
C. Machine.config
D. Root Web.config

2. You want to make a configuration setting change that will affect only the current web application. Which file will you change?
A. The Web.config file that is in the same folder as the Machine.config file
B. The Web.config file in the root of the web application
C. The Machine.config file
D. The Global.asax file

C H A P T E R 2: Using Master Pages, Themes, and Caching

Lesson 1: Using Master Pages

1. Which of the following statements about referencing master page methods and properties is true? (Choose all that apply.)
A. Content pages can reference private properties in the master page.
B. Content pages can reference public properties in the master page.
C. Content pages can reference public methods in the master page.
D. Content pages can reference controls in the master page.

2. You are converting an existing web application to use master pages. To maintain compatibility, you need to read properties from the master page. Which of the following changes are you required to make to ASPX pages to enable them to work with a master page? (Choose all that apply.)
A. Add an @ MasterType declaration.
B. Add an @ Master declaration.
C. Add a MasterPageFile attribute to the @ Page declaration.
D. Add a ContentPlaceHolder control.

3. You need to change the master page of a content page at run time. In which page event should you implement the dynamic changing?
A. Page_Load
B. Page_Render
C. Page_PreRender
D. Page_PreInit

Lesson 2: Using Themes

1. Which of the following theme applications will override an attribute that you specified directly on a control? (Choose all that apply.)
A. A theme specified by using @ Page Theme=”MyTheme”
B. A theme specified by using @ Page StyleSheetTheme=”MyTheme”
C. A element in the Web.config file
D. A element in the Web.config file

2. Which of the following is a valid skin definition inside a skin file?
A. </
asp:Label>
B.
Text="Label">
C.
D.

3. You need to allow users to choose their own themes. In which page event should you specify the user-selected theme?
A. Page_Load
B. Page_Render
C. Page_PreRender
D. Page_PreInit

Lesson 3: Caching

1. You are creating an ASP.NET webpage that displays a list of customers generated by a database query. The user can filter the list so that only customers within a specific state are displayed. You want to  maximize the performance of your web application by using page output caching. You want to ensure that users can filter by state, but you are not concerned about displaying updates to the list of customers because the customer list doesn’t change very frequently. Which declarative @ OutputCache attribute should you configure?
A. VaryByParam
B. VaryByHeader
C. SqlDependency
D. VaryByCustom

2. You need to programmatically configure page output caching. Which object would you use?
A. Request
B. Response
C. Application
D. Server

3. You want to cache an object but have it automatically expire in 10 minutes. How can you do this?
A. Directly define the Cache item.
B. Call Cache.Get.
C. Call Cache.Insert.
D. Cast DateTime.Now.AddMinutes(10) to the Cache type.

4. Which tool can you use to create a cache dependency? (Choose all that apply.)
A. An HTTP header
B. A file
C. A time span
D. A registry key
E. Another object in the Cache



C H A P T E R 3: Handling Events and Managing State

Lesson 1: Understanding the ASP.NET Life Cycle and Handling Events

1. In which file should you write code to respond to the Application_Start event?
A. Any ASP.NET server page with an .aspx extension
B. Web.config
C. Global.asax
D. Any ASP.NET server page with an .aspx.vb or .aspx.cs extension

2. You need to log data to a database when a user’s session times out. Which event should you respond to?
A. Application_Start
B. Application_End
C. Session_Start
D. Session_End

3. You notice that clicking a CheckBox does not cause an automatic postback. You need the CheckBox to automatically post back so you can update the webpage based on server-side code. How do you make the CheckBox cause an automatic postback?
A. Set the AutoPostBack property to true.
B. Add JavaScript code to call the ForcePostBack method.
C. Set the PostBackAll property of the webpage to true.
D. Add server-side code to listen for the click event from the client.

4. You need to dynamically create an instance of a TextBox server control in a page. You do not use master pages. Based on the recommended best practices, in which page event would you create the server control to ensure that the view state is properly reconnected to the control on postback?
A. PreInit
B. Init
C. Load
D. PreRender

Lesson 2: Using Client-Side State Management

1. You need to store a user’s user name and password as he or she navigates to different pages on your site, so that you can pass those credentials to the server. Which type of state management should you use?
A. Client-side state management
B. Server-side state management

2. You need to track nonconfidential user preferences when a user visits your site, to minimize additional load on your servers. You distribute requests among multiple web servers, each running a copy of your application. Which type of state management should you use?
A. Client-side state management
B. Server-side state management

3. You are creating an ASP.NET webpage that allows a user to browse information in a database. While the user accesses the page, you need to track search and sorting values. You do not need to store the information between visits to the webpage. Which type of client-side state management would meet your requirements and be the simplest to implement?
A. View state
B. Control state
C. Hidden fields
D. Cookies
E. Query strings

4. You are creating an ASP.NET website with dozens of pages. You want to allow the user to set user preferences and have each page process the preference information. You want the preferences to be remembered between visits, even if the user closes the browser. Which type of client-side state management meets your requirements and is the simplest to implement?
A. View state
B. Control state
C. Hidden fields
D. Cookies
E. Query strings

5. You are creating an ASP.NET web form that searches product inventory and displays items that match the user’s criteria. You want users to be able to bookmark or send search results in email. Which type of client-side state management meets your requirements and is the simplest to implement?
A. View state
B. Control state
C. Hidden fields
D. Cookies
E. Query strings

Lesson 3: Using Server-Side State Management

1. You need to store state data that is accessible to any user who connects to your web application and ensure that it stays in memory. Which collection object should you use?
A. Session
B. Application
C. Cookies
D. ViewState

2. You need to store a value indicating whether a user has been authenticated for your site. This value needs to be available and checked on every user request. Which object should you use?
A. Session
B. Application
C. Cookies
D. ViewState

3. Your application is being deployed in a load-balanced web farm. The load balancer is not set up for user server affinity. Rather, it routes requests to servers based on their load. Your application uses session state. How should you configure the SessionState mode attribute? (Choose all that apply.)
A. StateServer
B. InProc
C. Off
D. SqlServer



C H A P T E R 4: Using Server Controls

Lesson 1: Exploring Common Server Controls

1. To add an HTML server control to a webpage, you must drag an HTML element from the Toolbox to the webpage and then perform which of the following tasks?
A. Add the attribute run="server" to the control element in Source view.
B. Double-click the HTML element to convert it to an HTML server control.
C. Add the attribute runat="server" to the control element in Source view.
D. Select the HTML element in Design view and set the RunAt property to true in the Properties window.

2. You are creating a web form that displays a stock chart. Users can choose from three different sizes for the chart: small, medium, and large. How could you implement the user interface? (Choose all that apply. Each answer forms a complete solution.)
A. Add a RadioButtonList control.
B. Add three RadioButton controls. Set the GroupName property of all controls to ChartSize.
C. Add a CheckBoxList control.
D. Add three CheckBox controls. Set the GroupName property of all controls to ChartSize.

3. You are creating a webpage that has several related buttons, such as Fast Forward, Reverse, Play, Stop, and Pause. You want to create a single event handler that processes the postback from these Button controls. Which of the following should you do to handle the event while writing the least amount of code?
(Choose all that apply. Each answer forms part of the complete solution.)
A. Handle the Button.Command event.
B. Handle the Button.Load event.
C. Define the Button.CommandName property of all controls to PlaybackControl.
D. Define the Button.CommandName property so that each control has a unique value.

Lesson 2: Exploring Specialized Server Controls

1. Which of the following represents the best use of the Table, TableRow, and TableCell controls?
A. Creating and populating a table in Design view
B. Displaying data from a collection in a grid format
C. Creating a table of static images stored in a folder on your site
D. Providing layout for dynamically generated controls

2. Your graphics department just completed an elaborate image that shows the product lines that your company sells. Some of the product line graphics are circular, others are rectangular, and others are complex shapes. You want to use this image as a menu on your website. What is the best way to incorporate the image into your website?
A. Use ImageButton and use the x-coordinate and y-coordinate that are returned when the user clicks to figure out what product line the user clicked.
B. Use the Table, TableRow, and TableCell controls, break the image into pieces that are displayed in the cells, and use the TableCell control’s Click event to identify the product line that was clicked.
C. Use the MultiView control and break up the image into pieces that can be displayed in each View control for each product line. Use the Click event of the View to identify the product line that was clicked.
D. Use an ImageMap control and define hot spot areas for each of the product lines. Use the PostBackValue to identify the product line that was clicked.

3. You are creating a website that collects a lot of data from your users. The data collection spreads over multiple webpages. When the user reaches the last page, you need to gather all of the data, validate it, and save it to the database. You notice that it can be rather difficult to gather the data that is spread over multiple pages, and you want to simplify the development of this application. What control should you use to solve this problem?
A. The View control
B. The TextBox control
C. The Wizard control
D. The Panel control

C H A P T E R 5: Input Validation and Site Navigation

Lesson 1: Performing Input Validation

1. You need to validate a vendor ID entered by a user. The valid vendor IDs exist in a database table. How can you validate this input?
A. Provide a RegularExpressionValidator control and set the ValidationExpression property to /DbLookup{code}.
B. Provide a RangeValidator control, and set the MinValue property to
DbLookup(code) and the MaxVaue property to DbLookup(code).
C. Provide a CustomValidator control with server-side code to search the database for the code.
D. Provide a CompareValidator control and set the compare expression to the name of a server-side function that performs a database lookup of the code.

2. You have created a webpage that contains many controls that are validated by using validation controls. This page also contains Button controls that perform postbacks. You disabled all of the client-side validation and noticed that when you clicked any of the Button controls, the code in the Click event handler was executing even when some of the controls did not have valid data. How can you best solve this problem to ensure that code is not executed when invalid data exists?
A. In the Click event handler method for each of your Button controls, test the webpage’s IsValid property and exit the method if this property is false.
B. In the Load event handler method of the webpage, test the webpage’s IsValid property and exit the method if this property is false.
C. Re-enable the client-side script to disable postback until valid data exists.
D. Add the runat="server" attribute to all of the validation controls.

3. You have created an elaborate webpage that contains many validated controls. You want to provide a detailed message for each validation error, but you don’t have space to provide the detailed message next to each control. What can you do to indicate an error at the control and list the detailed error messages at the top of the webpage?
A. Set the Text property of the validator control to the detailed message and set the ErrorMessage property to an asterisk. Place a ValidationSummary control at the top of the webpage.
B. Set the ErrorMessage property of the validator control to the detailed message and set the Text property to an asterisk. Place a ValidationSummary control at the top of the webpage.
C. Set the ToolTip property of the validator control to the detailed message and set the ErrorMessage property to an asterisk. Place a ValidationSummary control at the top of the webpage.
D. Set the ToolTip property of the validator control to the detailed message and set the Text property to an asterisk. Place a ValidationSummary control at the top of the webpage.

Lesson 2: Performing Site Navigation

1. Which of the following server-side methods of the HttpServerUtility class can be used to navigate to a different webpage without requiring a round trip to the client?
A. Redirect
B. MapPath
C. Transfer
D. UrlDecode

2. Which control automatically uses the Web.sitemap file to display site map information to a user on a webpage?
A. Menu
B. TreeView
C. SiteMapDataSource
D. SiteMapPath

3. You want to provide an Up button for your webpages that users can click to navigate one level higher on your website. You want to define the hyperlink programmatically by using the site map. Which class can you use to access the site map content to accomplish this?
A. SiteMapPath
B. SiteMapDataSource
C. SiteMap
D. HttpServerUtility

Lesson 3: Using Web Parts

1. Which of the following can be a Web Part? (Choose all that apply.)
A. A control based on the Web User Control template
B. A standard Label control
C. A type derived from WebPart
D. A master page

2. Which of the following are required to enable users to change the title of a Web Part?
(Choose all that apply.)
A. LayoutEditorPart
B. EditorZone
C. CatalogZone
D. AppearanceEditorPart

3. You have developed a webpage with many different Web Part components. Some Web Parts are enabled by default, and you want to give the user the ability to display others. Which classes should you use?
(Choose all that apply.)
A. LayoutEditorPart
B. DeclarativeCatalogPart
C. CatalogZone
D. AppearanceEditorPart

4. You have created a Web Part control that prompts the user for personalization information, including his or her name, region, and preferences. You want other controls to be able to read information from this control to customize the information they display. How should you modify your Web Part to enable other Web Parts to connect to it?
A. Create a method that shares the user’s information, and add the ConnectionConsumer attribute to that method.
B. Create a method that shares the user’s information, and add the ConnectionProvider attribute to that method.
C. Create a public property that shares the user’s information, and add the Connection- Consumer attribute to that method.
D. Create a public property that shares the user’s information, and add the Connection- Provider attribute to that method.


C H A P T E R 6: Globalization and Accessibility

Lesson 1: Configuring Globalization and Localization

1. You need to create a webpage that is available in both the default language of English and for users whose browsers identify them as German. Which of the following resource files should you create? (Choose all that apply.)
A. App_LocalResources/Page.aspx.resx.de
B. App_LocalResources/Page.aspx.resx
C. App_LocalResources/Page.aspx.de.resx
D. App_LocalResources/Page.aspx.en.resx

2. What must you do to enable users to select their own language preferences (outside of browser and machine settings)? (Choose all that apply.)
A. Set the Page.Culture property.
B. Set the Page.UICulture property.
C. Override the Page.InitializeCulture method.
D. Override the Page.ReadStringResource method.

3. What markup would you write to explicitly attach the local resource, SubmitButtonText, found inside the application’s collection of MyLocalResources.aspx..resx files, to the Text property of a button control?
A.
B.
C. .
D.

4. You add a global resource with the name Login by using Visual Studio. How can you access that global resource programmatically?
A. Resources.Resource.Login
B. Resources.Resource(“Login”)
C. Resources(“Login”)
D. Resources.Login

Lesson 2: Configuring Accessibility

1. Which Image properties can you define to enable screen readers to describe a picture on a webpage? (Choose all that apply.)
A. AccessKey
B. AlternateText
C. DescriptionUrl
D. ToolTip

2. Which of the following are accessibility features provided by ASP.NET?
(Choose all that apply.)
A. Controls provide properties that enable you to provide hidden descriptions that are available to screen readers.
B. Controls are displayed in high contrast by default.
C. Controls that include a list of links at the top provide hidden links to skip over the links.
D. Controls display text in large font sizes by default.

3. For which of the following guidelines does ASP.NET provide automated testing?
(Choose all that apply.)
A. WCAG Priority 1
B. WCAG Priority 2
C. ADA
D. Access Board Section 508


C H A P T E R 7: Creating Custom Web Controls

Lesson 1: Creating User Controls

1. You want to create a user control that will encapsulate basic data entry functionality and that will be reused across a site. What steps should you take?
(Choose all that apply.)
A. Create an ASPX file and use the @ Register directive at the top of the page to indicate that the markup in the file is a user control.
B. Create a code-behind file for your user control that contains a class that inherits from System.Web.UI.UserControl.
C. Create a code-behind file for your user control that contains a class that inherits from System.Web.UI.Page.
D. Create an ASCX file and use the @ Control directive at the top of the page to indicate that the markup in the file is a user control.

2. You want to consume a user control on a page. However, you do not know the number of instances you want to create. This information will be available at run time. Therefore, you want to dynamically create these controls. Which actions should you take?
(Choose all that apply.)
A. Add the controls by using the Controls.Add method of the page instance.
B. Add the controls by using the Controls.Add method of the form instance.
C. Call the form’s LoadControl method for each control you want to add to the page.
D. Call the page’s LoadControl method for each control you want to add to the page.

3. You want to create a user control to display data, but you are concerned that you don’t know how the webpage designers want to format the data. Also, some of the page designers mention that the format of the data might be different, depending on the webpage. How can you best create a user control to solve this problem?
A. Create a separate user control for each webpage and get each webpage designer to tell you the format to implement in each user control.
B. Create a separate user control for each variation of the format after the webpage designers give you the desired formatting options.
C. Create a templated user control that exposes the data to the webpage designers so they can specify their desired format.
D. Create a user control that simply renders the data and let the webpage designers specify the style properties for the user control.

4. You have two TextBox controls inside your user control. You want to allow a developer using the user control to initialize, read, and modify the Text property of these controls.
What step should you take?
A. Add a constructor to the user control. The constructor should take parameters for each of the TextBox.Text properties. It will then set these parameter values appropriately.
B. Create properties on the user control that allow users to get and set the Text property of each TextBox control.
C. You don't need to do anything. Controls added to a user control, by default, expose their default property.
D. Add code to the Init method of the user control. This code should raise an event.
The page that hosts the control

Lesson 2: Creating Custom Web Server Controls

1. You are creating a custom web server control that extends the features of the ASP.NET Button control. Which steps should you take?
(Choose all that apply.)
A. Ensure that your control inherits from the WebControl class and exposes the base Button control as a property of the class.
B. Ensure that your control inherits directly from the Button control.
C. Override the Render method of your control and be sure to call base.Render (C#) or MyBase.Render (Visual Basic).
D. Override the RenderChildren method of your control and be sure to call base.RenderChildren (C#) or MyBase.RenderChildren (Visual Basic).

2. You want to define a custom image to be displayed in the Toolbox for your custom web server control. Which actions do you take?
(Choose all that apply.)
A. Set a reference to the System.Design namespace.
B. Set a reference to the System.Drawing namespace.
C. Add the ToolboxData attribute to the class.
D. Add the ToolboxBitmap attribute to the class.

3. You are going to create a custom web server control that inherits directly from the WebControl class. Which method do you need to override to get your control to display in the browser window?
A. OnInit
B. Finalize
C. ToString
D. Render

4. You are creating a composite control. You create a class that inherits from the CompositeControl class. What method must be overridden so you can provide code to instantiate the child controls and set their properties?
A. CreateChildControls
B. DataBindChildren
C. CreateControlStyle
D. BuildProfileTree


C H A P T E R 8: Debugging and Deploying

Lesson 1: Debugging Websites

1. You are debugging an application on a test server. You have an issue on a particular page and need to get the error details. You do not want to turn on debugging for the entire site. What actions should you take?
(Choose all that apply.)
A. In the Web.config file, set the debug attribute of the compilation element to true.
B. In the Web.config file, set the debug attribute of the compilation element to false.
C. On the page that throws the error, set the debug attribute of the @ Page directive to true.
D. On the page that throws the error, set the debug attribute of the @ Page directive to false.

2. You are deploying your application to a production environment. You want to redirect users to a default error page if they encounter any unhandled exceptions or HTTP errors within the site. You also want to indicate the user’s requested resource on the error page to help with support calls. What actions should you take?
(Choose all that apply.)
A. Set the redirect attribute of the error element to an error page within your site.
B. Set the defaultRedirect attribute of the customErrors element to an error page within your site.
C. Use the statusCode query string parameter to retrieve the requested resource to display on the error page.
D. Use the aspxerrorpath query string parameter to retrieve the requested resource to display on the error page.

3. You are investigating an error that only occurs when the application is deployed to the development or test server. You need to debug this error remotely. What actions should you take?
(Choose all that apply.)
A. Run the Remote Debugging Monitor (Msvsmon.exe) on the development computer that is doing the debugging. Use the tool to define connection rights to the server you want to debug.
B. Run the Remote Debugging Monitor (Msvsmon.exe) on the server you want to debug. Use the tool to define connection rights for the developer doing the debugging.
C. In Visual Studio, use the Attach To Process dialog box to attach to the ASP.NET process on the server you want to debug.
D. In Visual Studio, use the Attach To Process dialog box to attach to the browser process that is running the application you want to debug.

Lesson 2: Troubleshooting Websites

1. You want to identify which event in the webpage life cycle takes the longest time to execute. How can you accomplish this?
A. Turn on ASP.NET tracing and run the website. After that, review the trace results.
B. To each of the life-cycle events, add a line of code that will print the current time.
C. In the Web.config file, add the monitorTimings attribute and set it to true.
D. In the website properties, turn on the performance monitor and run the website. After that, open the performance monitor to see the timings.

2. You want to run a trace continuously to enable you to quickly look at the 10 most recent traces from anyone using your website, but you are concerned about filling your hard drive with excessive data. Which of the following settings will accomplish your objective?
A.
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
mostRecent="true"
/>
B.
enabled="true"
requestLimit="10"
pageOutput="true"
traceMode="SortByTime"
localOnly="true"
mostRecent="true"
/>
C.
enabled="true"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
mostRecent="false"
/>
D.
enabled="true"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="false"
mostRecent="true"
/>

3. You are interested in examining the data that is posted to the web server. What trace result section can you use to see this information?
A. The Control Tree section
B. The Headers Collection section
C. The Form Collection section
D. The Server Variables section

4. You want to configure ASP.NET health monitoring to log information every time a user fails to log on to the server. Which web event class should you use?
A. WebRequestEvent
B. WebAuditEvent
C. WebApplicationLifetimeEvent
D. WebAuthenticationSuccessAuditEvent

Lesson 3: Deploying Websites

1. You need to add a registry entry to make your application function. In which phase of the Web Setup Project should you add the registry entry?
A. Install
B. Commit
C. Rollback
D. Uninstall
2. You need to make a change to an operating system–related registry entry to make your
application function. You want to ensure that you remove this change if setup is cancelled
or the application is removed from the computer. In which phases should you undo your
registry modification? (Choose all that apply.)
A. Install
B. Commit
C. Rollback
D. Uninstall
3. Which of the following deployment tools enables multiple developers to work on a site
simultaneously while detecting potential versioning conflicts?
A. A setup project
B. A Web Setup Project
C. The Copy Web tool
D. The Publish Web Site tool
4. Which of the following deployment tools has the potential to improve responsiveness
of the website to end users?
A. A setup project
B. A Web Setup Project
C. The Copy Web tool
D. The Publish Web Site tool


C H A P T E R 9: Working with Client-Side Scripting, AJAX, and jQuery

Lesson 1: Creating AJAX-Enabled Web Forms

1. You are working on a long data-entry webpage. In the middle of the page, you need to reach out to the server to get information based on a user’s entry for a related field. However, you do not want the user to lose his or her focus or context within the page. Therefore, you decide to implement this feature by using the ASP.NET AJAX controls. Which of these controls must you add to the page to enable this scenario? (Choose all that apply.)
A. UpdatePanel
B. AsyncPostBackTrigger
C. ScriptManager
D. ScriptManagerProxy

2. You need to write a control that will be used across multiple pages. This control should contain updated sales figures. The control should update itself at various intervals if a containing page is left open. Which controls should you use to enable this scenario?
(Choose all that apply.)
A. UpdatePanel
B. Timer
C. ScriptManager
D. ScriptManagerProxy

3. You have an UpdatePanel control defined on a page. You need to indicate that a specified Button control outside of the UpdatePanel should cause the UpdatePanel to execute an update. What steps should you take?
A. Set the AsyncPostBackTrigger attribute of the UpdatePanel to the ID of the Button control.
B. Set the AsyncPostBackTrigger attribute of the Button control to the ID of the UpdatePanel.
C. Add a Trigger control to the AsyncPostBackTriggers section of the UpdatePanel. Set the ControlID attribute of the Trigger control to the ID of the Button control.
D. Add an AsyncPostBackTrigger control to the Triggers section of the UpdatePanel. Set the ControlID attribute of the AsyncPostBackTrigger control to the ID of the Button control.

4. You are creating a page that contains an UpdatePanel control for partial-page updates. You want to notify the user that the update is processing only if the update takes longer than five seconds. Which actions should you take?
A. Add a second UpdatePanel to the page. Set it to trigger based on the first Update-Panel. Set the contents of this UpdatePanel to read “Processing, please wait.”
B. Add an UpdateProgress control to the UpdatePanel. Set its DisplayAfter attribute to 5,000. Set its ProgressTemplate contents to read “Processing, please wait.”
C. Add a ProgressBar control to the page. Write code on the server to call back to the client synchronously to update the ProgressBar control after five seconds.
D. Create a hidden
tag on your page that contains the text “Processing, please wait.” Set the
tag’s ID to match that of the UpdatePanel. Set the Update-Panel control’s Interval property to 5,000.

Lesson 2: Creating Client Scripts with the Microsoft AJAX Library

1. Which of the following lines of JavaScript registers a new class to be used as an extension to a DOM element?
A. MyNamespace.MyClass.registerClass('MyNamespace.MyClass ', Sys.UI.Control);
B. MyNamespace.MyClass.registerClass('MyNamespace.MyClass ', null, Sys.IDisposable);
C. MyNamespace.MyClass.registerClass('MyNamespace.MyClass ', null);
D. MyNamespace.MyClass.registerClass('MyNamespace.MyClass ', Sys.UI.Behavior);

2. You are creating an AJAX component that does an asynchronous postback to the server for partial-page updates. You need your code to be notified when the partialpage response first comes back from the server. Which event should you intercept?
A. endRequest
B. pageLoading
C. pageLoaded
D. beginRequest

3. You write a JavaScript class that uses the Microsoft AJAX Library. You intend to use the class on a webpage. Which of the following actions should you take?
A. Add the following markup to the section of the ASPX page.
B. Add a ScriptManager control to your page. It automatically finds your .js files in your solution. You can then work with them by using IntelliSense.
C. Add a ScriptManager control to your page. Add a reference nested inside the ScriptManager control that points to your JavaScript file.
D. Use the ScriptReference class in your code-behind file and set its path to the path of your .js file.

4. You want to create a custom control that works as an AJAX client behavior. What action(s) should you take?
(Choose all that apply.)
A. Create a custom server-side class that inherits from a valid System.Web.UI.Control.
B. Create a custom server-side class that inherits from ExtenderControl.
C. Create a custom server-side class that implements the interface IScriptControl.
D. Create a custom server-side class that is decorated with the attribute TargetControlType.

Lesson 3: Implementing jQuery

1. You need to write jQuery code to select the first heading (h2) tag on the page and then slowly fade the item into view. Which line of code would accomplish this task?
A. $("#h21").fadeIn(500);
B. $("h2:first").fadeIn("slow");
C. $(".h2:first").fadeIn(500);
D. $("h2:first").fadeIn(500);

2. You want to execute a function after the DOM has loaded. This function should bind an event code to be run when the user presses a key on the keyboard inside a text box control with the textBox1 ID. Which steps should you take?
(Choose all that apply.)
A. Bind to the keyPress event by using the following code.
$("#textBox1").bind("keyPress", ())
B. Add your event binding code to the $(document).ready() event at the top of your script.
C. Add your event binding code to the $(document).load() event at the top of your script.
D. Bind to the keyPress event by using the following code.
$("#textBox1").add("keyPress", ()).

3. You want to use the .ajax() method to call a web method named GetCityCodes. This web method is contained on the same webpage as the jQuery code and UI markup. This method should be called by using JSON. The web method takes the state parameter. Which of the following calls would you use?
A. $.ajax({
type: "POST",
dataType: "json",
contentType: "application/json",
url: "CityLookup.aspx/GetCityCodes",
data: "{'state': '" + state + "'}",
success: function (data) {
alert(data.d);
},
B. $.ajax({
type: "POST",
dataType: "json",
contentType: "application/json",
url: "CityLookup.asmx/GetCityCodes",
data: "{'state': '" + state + "'}",
success: function (data) {
alert(state.d);
},
C. $.ajax({
type: "POST",
dataType: "json",
contentType: "application/json",
url: "CityLookup.aspx/GetCityCodes/" + state,
success: function (data) {
alert(data.d);
},
D. $.ajax({
type: "POST",
dataType: "json",
contentType: "application/json",
url: "CityLookup.asmx/GetCityCodes",
data: "state:" + state,
success: function (data) {
alert(data.d);
},

4. You want to use an HTTP GET to retrieve a basic text file from the server by using AJAX and jQuery. Which of the following jQuery methods would you use?
A. $.post()
B. $.getScript()
C. $getJSON()
D. $.get()


C H A P T E R 10: Writing and Working with HTTP Modules and Web Services

Lesson 1: Creating HTTP Handlers and HTTP Modules

1. You need to have ASP.NET dynamically generate Microsoft Word documents when a web browser requests a file ending in a .docx extension. How can you do this?
A. Implement the IPartitionResolver interface.
B. Implement the IHttpModule interface.
C. Implement the IHttpHandler interface.
D. Implement the IHttpHandlerFactory interface.

2. You are writing a custom HTTP handler to be hosted in IIS 7.0 integrated mode. You intend to register the handler by using the Web.config file. What should you do?
(Choose all that apply.)
A. Define an element inside the element.
B. Define an element inside the element.
C. Add a element to the element.
D. Add a element to the element.

3. You want to create custom code that will be run for each request made to a website.
What steps should you take? (Choose all that apply.)
A. Create a class file that implements the IHttpHandler interface.
B. Override the Init method to connect your code to specific application events.
C. Override the ProcessRequest method to wire up your code to specific application events.
D. Create a class file that implements the IHttpModule interface.

Lesson 2: Creating and Consuming XML Web Services

1. You want to create a new web service that will expose multiple methods that are meant to work with user-specific data via a transaction. You decide to use ASP.NET session state to manage the user’s context on the server between web service requests. How should you define your web service?
A. Define a class that inherits from WebServiceAttribute.
B. Define a class that inherits from WebService.
C. Define a class that inherits from WebMethodAttribute.
D. Do not inherit from a base class. Hosting the web service in ASP.NET is sufficient.

2. You want to consume an existing web service from your ASP.NET website. What actions should you take?
(Choose all that apply.)
A. Use the Add Reference dialog box to set a reference to the WSDL file that contains the web service.
B. Use the Add Web Reference dialog box to point to the URL of the web service.
C. Write a method in your website that has the same function signature as your web service. Do not implement this method. Instead, mark it with the WebMethod attribute.
D. Call a proxy class that represents your web service.

3. You need to secure your web service. The service will be accessed over the Internet by multiple systems of different types. Authentication information should be secured. You want to trust only those clients who have been verified as trusted. What type of security should you consider?
A. Windows Basic
B. Windows Digest
C. Client certificates
D. Custom SOAP headers

4. You want to create a web service and call it from client-side script. What actions should you take? (Choose all that apply.)
A. Add the ScriptService attribute to the web service class.
B. Write client-side JavaScript to call your service through a proxy object.
C. Add a ScriptManager class to your webpage. Set the ServiceReference to point to the ASMX web service.
D. Make sure that your webpage and service are in the same domain.

Lesson 3: Creating and Consuming WCF Services

1. You want to write a WCF service application. You intend to host the service in IIS and use ASP.NET to build the service. What type of project should you create?
A. A WCF Service library
B. A WCF service application
C. An ASP.NET Web Service application
D. A Windows Service application

2. You define your own custom type to be used with your WCF service. This type represents a product at your company. It contains several public properties. You want to expose this type so that it can be serialized and defined by an XML Schema Definition (XSD) schema. What actions should you take? (Choose all that apply.)
A. Mark your product class with the DataContract attribute.
B. Mark your product class with the ServiceContract attribute.
C. Mark the public members of your product class with the OperationContract attribute.
D. Mark the public members of your product class with the DataMember attribute.

3. You want to expose a portion of your data model as a service by using OData. Which actions should you take?
(Choose all that apply.)
A. Create a service class that inherits from DataService.
B. Create a service class that inherits from DataContract.
C. Indicate what the service should expose inside the InitializeService method.
D. Indicate what the service should expose inside the Init method.

4. You want to write a client to work with a WCF Data Service. Which actions should you take? (Choose all that apply.)
A. Set a web reference to the data service.
B. Set a service reference to the data service.
C. Create an instance of the data service proxy and pass a URI object to point to the data service.
D. Use the classes in System.Data.Services.Client to write code to access the data exposed by the service.


C H A P T E R 11: Connecting to and Querying Data with LINQ

Lesson 1: Getting Started with LINQ

1. Against which of the following classes can you write a LINQ query?
(Choose all that apply).
A. DataSet
B. List
C. Array
D. Dictionary

2. You need to write a LINQ query to retrieve a list of state hospitals. The results should be sorted and grouped first by county. For each county, the hospitals should be sorted by city. Which of the following LINQ queries would you write?
(Choose all that apply.)
A.
Visual Basic Code
Dim hsQ = From hspt In hospitals
Order By hspt.County, hspt.City
Group hspt By hspt.County Into hsptGroup = Group
C# Code
var hsQ = from hspt in hospitals
orderby hspt.County, hspt.City
group hspt by hspt.County;
B.
Visual Basic Code
Dim hsQ = From hspt In hospitals
Order By hspt.County
Group hspt By hspt.County Into hsptGroup = Group
Order By hsptGroup.Last.City
C# Code
var hsQ = from hspt in hospitals
orderby hspt.County
group hspt by hspt.County into hsptGroup
orderby hsptGroup.Last().City
select hsptGroup;
C.
Visual Basic Code
Dim hsQ = From hspt In hospitals
Order By hspt.County, hspt.City
Group hspt By hspt.County Into hsptGroup = Group
Order By hsptGroup.First.County
C# Code
var hsQ = from hspt in hospitals
orderby hspt.County
group hspt by hspt.County into hsptGroup
orderby hsptGroup.Key
select hsptGroup;
D.
Visual Basic Code
Dim hsQ = From hspt In hospitals
Order By hspt.City
Group hspt By hspt.County Into hsptGroup = Group
Order By hsptGroup.First.County
C# Code
var hsQ = from hspt in hospitals
orderby hspt.City
group hspt by hspt.County into hsptGroup
orderby hsptGroup.First().County
select hsptGroup;

3. You want to merge the results from two separate LINQ queries into a single result set.
How would you accomplish this?
A. Use the ToList method.
B. Use the DataContractJsonSerializer class.
C. Use the XElement class.
D. Use the Concat method.

Lesson 2: LINQ and ADO.NET

1. You need to write a where clause in a LINQ query against a strongly typed DataSet of universities (from u in universities). The where clause should select all universities with more than 10,000 enrolled students. Which where clause would you write?
A. where u.Field("EnrolledStudents") > 10000
B. where u.EnrolledStudents > 10000
C. C#: where u[“EnrolledStudents”] > 10000
Visual Basic: where u(“EnrolledStudents”) > 10000
D. where university.Fields.EnrolledStudents > 10000

2. Which of the following objects represents a LINQ to SQL O/R map?
A. DataSet
B. XElement
C. ObjectContext
D. DataContext

3. You are using an Entity Data Model object. Which of the following lines of code will initialize this object and connect to the associated database?
(Choose all that apply.)
A. MyModel.myEntities model = new MyModel.myEntitites()
B. MyModel.myEntities model = new MyModel.myEntitites(cnnString)
C. PubsModel.pubsEntities pubs = new PubsModel.pubsEntities(
new System.Data.EntityClient.EntityConnection(cnnString))
D. MyModel.myEntities model = new MyModel.myEntitites(
new DataContext(cnnString))


C H A P T E R 12: Working with Data Source Controls and Data-Bound Controls

Lesson 1: Connecting to Data with Data Source Controls

1. You have a data context map for your SQL Server database defined inside a class file. You need to connect to this data by using a data source control. Which data source control should you use?
A. ObjectDataSource
B. SqlDataSource
C. SiteMapDataSource
D. LinqDataSource

2. You are using an ObjectDataSource control to connect to a business object. Which attributes of the control must you set to return data for the data source?
(Choose all that apply.)
A. TypeName
B. SelectMethod
C. DataSourceId
D. SelectParameters

3. You want to apply caching to your data source control to increase your scalability for frequently used data. You want to set the cache to expire every 60 seconds. Which attributes of your data source control should you set to do so?
(Choose all that apply.)
A. CacheTimeout
B. CacheDuration
C. EnableCaching
D. DisableCaching

4. You are using an EntityDataSource control on your page. You need to write a custom query that uses a parameter in the Where clause. What actions should you take?
(Choose all that apply.)
A. Set the command by using the EntitySetName property.
B. Set the command by using the CommandText property.
C. Add a WhereParameters section to the EntityDataSource control markup.
D. Name the parameter by using the @ ParamName construct inside the Where parameter definition.

Lesson 2: Working with Data-Bound Web Server Controls

1. You are creating a data-bound CheckBoxList control that allows a user to select options for configuring a vehicle. When the data is displayed to the user, you want the OptionName column to display. When the data is posted back to the server, you need the OptionId column value for all selected items. Which of the following attribute definitions would you set?
(Choose all that apply.)
A. DataTextField=OptionId
B. DataTextField=OptionName
C. DataValueField=OptionId
D. DataValueField=OptionName

2. You want to display a list of suppliers on a webpage. The supplier list must display 10 suppliers at a time, and you require the ability to edit individual suppliers. Which web control is the best choice for this scenario?
(Choose all that apply.)
A. The DetailsView control
B. The Repeater control
C. The GridView control
D. The ListView control

3. You want to display a list of parts in a master-detail scenario so that users can select apart number from a list that takes a minimum amount of space on the webpage. When the part is selected, a DetailsView control displays all the information about the part and allows users to edit the part. Which web control is the best choice to display the part number list for this scenario?
A. The DropDownList control
B. The RadioButtonList control
C. The FormView control
D. The TextBox control

Lesson 3: Working with ASP.NET Dynamic Data

1. You need to add metadata to your data context object, Invoice, in order to change how invoices are handled by Dynamic Data. Which actions should you take?
(Choose all that apply.)
A. Create a new partial class called Invoice in the App_Code directory.
B. Create a new class called InvoiceAnnotations in the App_Code directory.
C. Decorate the Invoice class with the MetadataTypeAttribute class.
D. Decorate the InvoiceAnnotations class with the ScaffoldTableAttribute class.

2. You have defined a custom field template user control for changing the way an Invoice number is edited. You want to apply this control to the Invoice.Number property. Which data annotation attribute class would you use to do so?
A. MetadataType
B. Display
C. Editable
D. UIHint

3. You want to implement custom business logic that should run when the InvoiceNumber property is modified. What actions should you take?
(Choose all that apply.)
A. Add a CustomValidator control to the DynamicData/FieldTemplates/Integer_Edit.asax file. Set this control to process custom logic to validate an invoice number.
B. Extend the OnInvoiceNumberChanged partial method inside the Invoice partial class to include additional validation logic.
C. Extend the OnInvoiceNumberChanging partial method inside the Invoice partial class to include additional validation logic.
D. If the logic fails, throw a ValidationException instance.


C H A P T E R 13: Implementing User Profiles, Authentication, and Authorization

Lesson 1: Working with User Profiles

1. Which of the following Web.config files correctly enables the website to track the age of anonymous users in a variable of type Int32?
A.
B.
C.
D.
2. You want to create a user profile that uses a custom type as one of the profile properties.
What actions must you take?
(Choose all that apply.)
A. Mark your class as serializable.
B. Set the type attribute of the profile property to the fully qualified name of your custom type.
C. Add the group element to your profile property. Add one element to the group element for each property in your custom type. Set each element’s name to match that of a property in your custom type.
D. Add your custom type in the Machine.config file in the element.

Lesson 2: Using ASP.NET Membership

1. Which of the following controls provides a link for unauthenticated users to log on?
A. Login
B. LoginView
C. LoginStatus
D. LoginName

2. You are creating a web form that enables users to log on to your website. Which of the following ASP.NET controls should you add to the page? (Choose two answers.)
A. Login
B. CreateUserWizard
C. LoginName
D. PasswordRecovery

3. You have created an ASP.NET web form that enables users to create accounts with a CreateUserWizard control. After a new user creates an account, you want to redirect the user to a page listing the rules for your website. To which of the following events should you respond?
A. CreateUserWizard.Unload
B. CreateUserWizard.ContinueButtonClick
C. CreateUserWizard.CreatedUser
D. CreateUserWizard.Init

4. Which of the following Web.config segments correctly requires that all users be authenticated by using a Windows user account?
A.
B.
C.
D.

5. Given the following Web.config file, what permissions do users have to the Marketing folder?
A. Authenticated users and members of the FABRIKAM\Marketing group have access. All other users are denied access.
B. Members of the FABRIKAM\Marketing group have access. All other users are denied access.
C. All users, authenticated and unauthenticated, have access.
D. All users are denied access.

6. You are configuring NTFS file permissions for a website with the following
Web.config file:
For the Marketing folder, you remove all file permissions, and then grant read access to the FABRIKAM\John and FABRIKAM\Sam user accounts. John is a member of the FABRIKAM\Domain Users and FABRIKAM\Marketing groups. Sam is only a member of the FABRIKAM\Domain Users group. Which of the following users can access web
forms located in the Marketing folder?
A. Unauthenticated users
B. Authenticated users
C. Members of the FABRIKAM\Domain Users group
D. FABRIKAM\John
E. FABRIKAM\Sam


C H A P T E R 14: Creating Websites with ASP.NET MVC 2

Lesson 1: Understanding ASP.NET MV C Applications

1. You need to define a page that allows a user to add a new product to the product catalog. You are using ASP.NET MVC and the default structure and routing. Which actions do you take?
(Choose two.)
A. Add a class to the Controllers folder and name it Catalog. Add a method called AddProduct to this class.
B. Add a class to the Controllers folder and name it ProductController. Add a method called Add to this class.
C. Add a new folder to the Views folder and name it Product. Create a view inside this new folder and name it Add.aspx.
D. Add a new folder to the Views folder and name it AddProduct. Create a view inside this new folder and name it Catalog.aspx.
2. You have a very large website and you want to structure the files in this site logically so that they are easier to manage. What actions should you take?
(Choose all that apply.)
A. Create separate area folders inside the Models, Views, and Controllers folders. Name these folders based on the logical grouping in your site folder.
B. Ensure that the RegisterAllAreas() method is defined in your Application_Start method.
C. Create separate Controllers, Models, and Views folders within your area folders.
D. Create an Areas folder and add individual area folders based on the logical grouping in your site.
3. You are writing an action method inside your controller. You want to pass string data to the view and display that data inside the view. You are using the default MVC templates. What actions should you take?
(Choose all that apply.)
A. In your action method, add your string value to the ViewData collection.
B. In the view, reference the string value by using this inline code: <%: object %>.
C. Create a constructor for your view that takes a string value.
D. Reference the string value in the code-behind file for your view, and write it to the page.

Lesson 2: Creating Models, Views, and Controllers

1. You are writing an action method called ShipOrder inside the Order controller. The logic in your code indicates that you need to call the Shipment controller’s Status method as a result of your controller’s action method. Which line of code would accomplish this?
A. return View("Shipment.Status")
B. return redirect("Shipment/Status")
C. Response.Redirect("Shipment.aspx?action=Status")
D. return Content("Shipment.Status")
2. You want to add a default route for when requests are made to your site without the controller and action parameters in the URL. This default route should point to Default.aspx inside the view folder named Main. You create a controller named DefaultController. Which code would you write?
A.
Visual Basic Code
routes.MapRoute("HomePage", _
"{controller}/{action}", _
New With {.controller = "DefaultController", .action = "Default"} )
C# Code
routes.MapRoute("HomePage",
"{controller}/{action}",
new { controller = "DefaultController", action = "Default"} );
B.
Visual Basic Code
routes.MapRoute("Default", _
"{DefaultController}/{Default}", _
New With {.controller = "Default", .action = "Default"} )
C# Code
MapRoute("Default ",
"{ DefaultController }/{ Default }",
new { controller = "Default", action = "Default"} );
C.
Visual Basic Code
routes.MapRoute("Default", _
"{DefaultController}/{Default}")
C# Code
routes.MapRoute("Default ",
"{ DefaultController }/{ Default }");
D.
Visual Basic Code
routes.MapRoute("HomePage", _
"{controller}/{action}", _
New With {.controller = "Default", .action = "Default"} )
C# Code
routes.MapRoute("HomePage",
"{controller}/{action}",
new { controller = "Default", action = "Default"} );
3. You want to create a strongly typed view. What actions should you take? (Choose all that apply.)
A. Mark your @ Page directive to inherit from ViewPage.
B. Add a strong type as a parameter to the View method inside your action method.
C. Add a strong type to the ViewData collection inside your action method.
D. Mark your @ Page directive to include the ViewDataClass attribute and point to an entity inside your model.