Answer Key

1. D

2. C

3. D

4. B

5. A

6. C

7. A

8. D

9. C

10. A

11. D

12. A and C

13. C

14. C

15. C

16. B

17. D

18. A

19. D

20. C

21. D

22. D

23. B

24. A

25. D and E

26. A

27. C

28. C

29. B and C

30. D

31. C

32. C

33. B

34. B and D

35. C

36. B

37. B

38. C

39. B

40. A and D

41. D

42. C

43. C

44. D

45. A and E

46. C

47. C

48. D

49. A

50. E

51. D

52. A

53. A and C

54. A and C

55. D

56. B

57. C

58. D

59. A

60. B

Question 1

The correct answer is D. The <% %> code blocks in an ASPX page are placed inside a method that renders the user interface of an ASPX page. The <%= %> construct is used to display values from an ASP.NET code in the resulting Web page. Answer A is incorrect because the <script runat ="server"></script> code block is used to define class-level methods , properties, and variables . The code in these blocks is directly placed in the class definition when the code is dynamically compiled. Answer B is incorrect because the runat attribute of the <script> element should have the value server . Answer C is incorrect because the <script> element without the runat="server" attribute is not executed on the server and is passed to the browser. Answer E is incorrect because you should not use a semicolon while calling the method in the <%= %> construct.

Question 2

The correct answer is C. The Inherits attribute in the Page directive specifies a fully qualified name of a code-behind class from which the page should inherit. The Src attribute specifies the source filename of the code-behind class; this attribute is used when the code-behind class is not precompiled. Answers A and B are incorrect because the CodeBehind attribute is not used by the CLR (Common Language Runtime); it is used internally by Visual Studio .NET to link the ASPX page with the code-behind file. Answer D is incorrect because the ClassName attribute specifies the class name for the page that will be dynamically compiled when the page is requested ; it does not play any role in linking the ASP.NET page with the code-behind class or file.

Question 3

The correct answer is D. You should set the CausesValidation property of the Button control to false because doing so prevents validation from occurring when the button is clicked. Answers A and C are incorrect because the TextBox Web server control does not contain a CausesValidation property. Answer B is incorrect because setting the CausesValidation property of the Button control to true causes validation to occur when the button is clicked.

Question 4

The correct answer is B. By default, the SelectedIndexChanged event of the DropDownList control is fired only when the page is posted back to the server. By setting the AutoPostBack property of the control to true , you cause the page to post back as soon as a selection is changed in the list. Answer A is incorrect because the PreRender event does not cause a postback when a selection is changed in the drop-down list. Answer C is incorrect because the ListBox control also does not post back immediately when the selection is changed. Answer D is incorrect because the EnableViewState property indicates only whether the view state should be maintained for the drop-down list.

Question 5

The correct answer is A. The RequiredFieldValidator control ensures whether a value is entered or selected in the control. It can also ensure that the value in a control is different from the original value in the control, if the original value is supplied to the InitialValue property of the RequiredFieldValidator control. Answer B is incorrect because the Display property specifies how to display the inline error message; ValidatorDisplay.Dynamic ensures that the space for the validation control is dynamically added only when the validation fails. Answer C is incorrect because, by default, the Visible property is set to true . The Visible property has no control over the validation; it indicates only whether the control should be rendered on the page. Answer D is incorrect because the EnableClientScript property specifies whether the client-side validation should occur. By setting it to false , the validation occurs only on the server side.

Question 6

The correct answer is C. The ASP.NET validation server controls require client-side scripting support to perform validation on the client side. If the browser does not support scripting, the validation occurs only on the server side when the page is posted. Answer A is incorrect because, if the Enabled attribute had been set to false , the validation would not have occurred on either the client side or server side. Answer B is incorrect because the SmartNavigation attribute is used to enable smart navigation between post backs and has no control on validation. Answer D is incorrect because client-side validation works with Internet Explorer 4.0 or higher.

Question 7

The correct answer is A. To display custom error pages to all the users, the mode attribute of the <customErrors> element must be set to On . The defaultRedirect attribute of the customErrors element specifies the page to be displayed for any errors not listed. Answers B and D are incorrect because the mode attribute of the <customErrors> element is set to RemoteOnly , which would disable custom error pages for the local computer. Answer C is incorrect because the <error> element specifies an error status code and the resulting page to display.

Question 8

The correct answer is D. The database connection should be closed whether the information can be retrieved or not. The code in the finally block will be executed regardless of whether an exception is thrown. Answer A is incorrect because, if an exception occurs before the code that closes the SqlConnection object in the try block, the code will not be executed. Answer B is incorrect because in this case the SqlConnection object is closed only when a SqlException occurs. Answer C is incorrect because in this case the SqlConnection object is closed only when an exception other than SqlException occurs.

Question 9

The correct answer is C. In a page, to log errors into a custom log file, you need to provide an event handler for the Page.Error event. The Page.Error event occurs whenever an unhandled exception occurs in the page. Answer A is incorrect because the <error> element specifies an error HTTP status code and the redirect page for the HTTP status code. Answer B is incorrect because the ErrorPage attribute specifies the custom error page for an individual page. Answer D is incorrect because the Application_Error() event handler is generated whenever an unhandled exception occurs in the application rather than a page. The Application_Error() event handler should be placed in the global.asax file.

Question 10

The correct answer is A. To transfer execution to a page that is not processed by the ASP.NET process, you must use the Response.Redirect() method. Answers B and C are incorrect because these methods are used to redirect control to ASPX pages. Answer D is incorrect because the CreateObject() method creates instances of COM components .

Question 11

The correct answer is D. The SmartNavigation attribute offers several benefits to users running Internet Explorer 5.0 or higher, including focus persistence, minimized screen flashing, persistent scroll positioning, and better history management. Answers A, B, and C require more efforts because they involve writing code to implement the logic. Thus, none of these answers is "the easiest way."

Question 12

The correct answers are A and C. If the Web page loads the data for the controls at every page load, disabling the view state will make the page size much smaller and maximize performance. If the Web page only reads the data but does not update data in the session state, you can make the session state for the page read-only. This will eliminate the time taken by ASP.NET to store the data in the session state for the Web page. Answer B is incorrect because, by disabling the session state, the Web page will not be capable of displaying the username from the session in the greeting to the user. Answer D is incorrect because storing the session state in the SQL Server creates extra overhead.

Question 13

The correct answer is C. When you store session state data in SQL Server, you can take advantage of the robustness and data protection qualities of SQL Server. This includes the capability to preserve data even across server crashes. Answers A and B are incorrect because storing the session state in the ASP.NET worker process or StateServer process would not enable the recovery of data if the Web server were restarted. Answer D is incorrect because it disables session state.

Question 14

The correct answer is C. You want the information to be available across Web pages and browser restarts. Therefore, you should choose cookies because they allow you to store a small amount of information on the user's computer. Answers A, B, and D are incorrect because none of these options (hidden fields, view state, and sessions) can store information across browser restarts.

Question 15

The correct answer is C. You should use view state to store page-specific values. View state can store any type of object as long as it is serializable. Answers A and D are incorrect because both of these techniques store data global to the application and should not be selected for storing user-specific data. Answer B is incorrect because, although the session state is suitable for storing user-specific data, it is not required unless the data is used across pages and is too sensitive to be stored on the client side.

Question 16

The correct answer is B. By using varying output caching, you can store the output of the page for each product in the database. These pages can then quickly deliver information on the individual products without requiring a round trip to the database and creating output for each request. Answer A is incorrect because only varying output caching enables you to save information on each product. Answer C is incorrect because, even though it would save a round trip to the database, it would require the response to be created at each request that can be easily avoided by using varying output caching. Answer D is incorrect because fragment caching is used to cache output of user controls rather than ASPX pages.

Question 17

The correct answer is D. The processing of the file data takes time to load the Web page. Further, the output changes only when the data in the XML file changes; therefore, the best solution is to cache the DataSet object. This way, you can eliminate the consumption of server resources to create the DataSet object from scratch at every request. Answers A and B are incorrect because output caching cannot be made dependent on a file. Only data stored in the Cache object can be made dependent on other items in the data cache or on an external resource such as a file or directory. Answer C is incorrect because it only adds the DataSet object to the cache and does not set any dependencies.

Question 18

The correct answer is A. You need caching based on the state entered by the user; therefore, you need to set the VaryByControl attribute to txtState to cache different versions of the user control output by state. Answers B and D are incorrect because the VaryByParam attribute specifies the parameters of the Web page, rather than user control, for which the output cache is varied. Answer C is incorrect because the VaryByControl attribute does not work if * is passed ”it needs a list of controls in the user control for which the output cache is to vary.

Question 19

The correct answer is D. The DataView object represents a data-bindable, customized view of a data table, which is optimized for sorting, filtering, searching, editing, and navigation. Answers A and C are incorrect because they involve additional programming. Answer B is incorrect because it will impact the SQL Server database with additional hits.

Question 20

The correct answer is C. Although answers C and D both use the correct syntax of the Fill() method, the question clearly states the name of the table; therefore, it is recommended to use the name of the table when filling the DataSet . This is why answer D is incorrect. Answer A is incorrect because there is no overload of the Fill() method that accepts a single string parameter. Answer B is incorrect because there is no overload of the Fill() method that accepts two string parameters.

Question 21

The correct answer is D. Using the same connection string enables ADO.NET to reuse existing pooled database connections instead of creating new ones. This improves performance because creating new database connections is a costly operation. Answer B is incorrect because another application that uses the same database is already performing well. Answer C is incorrect because, if different connection strings are used, each request for the connection will create a new connection pool anyway. Therefore, increasing the maximum size of the pool will not matter. Answer A is incorrect because users are facing slow performance consistently and not just during the first execution.

Question 22

The correct answer is D. When you set the XmlWriteMode parameter of the DataSet.WriteXml() method to DiffGram , the output contains both original and current values. Answer A is incorrect because the DataSet.WriteXmlSchema() method writes the DataSet structure as an XML schema instead of writing XML data. Answers B and C are incorrect because setting the XmlWriteMode parameter to IgnoreSchema or WriteSchema writes only the current value of the data to the XML file.

Question 23

The correct answer is B. IsolationLevel.Serializable places a range lock on the database, thereby preventing other users from updating or inserting rows into the database until the transaction is complete. Answer A is incorrect because IsolationLevel.ReadCommitted holds the lock while the data is being read, but data can be changed before the transaction is complete. Answers C and D are incorrect because the BeginTransaction() method should be called on the SqlConnection object rather than the SqlCommand object.

Question 24

The correct answer is A. The ColumnMapping property determines how a column's values will be written when the WriteXml() method is called on a DataSet to write output to an XML document. When you set the ColumnMapping property of a column to MappingType.Attribute , that column of the table is mapped to an XML attribute. Answer B is incorrect because setting the ColumnMapping property of the column to MappingType.Element maps that column of the table to an XML element. Answers C and D are incorrect because XmlWriteMode.WriteSchema instructs the WriteXml() method to write the current contents of the DataSet as XML data along with the relational structure as an inline XSD schema. Writing an additional schema is not required in the question.

Question 25

The correct answers are D and E. Strings in Visual C# .NET are immutable, so concatenating multiple values into a string requires deleting and re-creating the string many times. The StringBuilder object is optimized for changing textual data. The GetString() method should be used rather than the GetValue() method to retrieve data because the typed methods are faster than the GetValue() method. Answer A is incorrect because stored procedures have much higher performance as compared to SQL statements. Answer B is incorrect because for a forward-only, read-only operation, the SqlDataReader object provides the best performance. Answer C is incorrect because the while loop provides better performance when compared to the for each loop.

Question 26

The correct answer is A. You can have only a single SqlDataReader object open on a single SqlConnection object. If you need a second SqlDataReader object, you must open a second SqlConnection object. Answers B and C are incorrect because the question asks for the likely cause of the error and not just an alternative approach. Answer D is incorrect because you want to retrieve multiple values from the database and the ExecuteScalar() method retrieves only the first column of the first row in the result set.

Question 27

The correct answer is C. Calling the GetChanges() method of a DataSet returns a new DataSet that contains only records that have been changed. Answer A is incorrect because the DataSet.Clone() method copies the structure of the DataSet but does not copy any data. Answer B is incorrect because the DataSet.Copy() method copies all the data instead of only the changed data. Answer D is incorrect because you do not want to merge two DataSet objects.

Question 28

The correct answer is C. To create a connection string for a SqlConnection object that uses Windows Integrated authentication, you need to specify the data source and the initial catalog and indicate that it is a secure connection. You can indicate that it is a secure connection by setting the Trusted_Connection or Integrated Security parameter to true or sspi . Answers A and B are incorrect because you do not specify the provider in the connection string when connecting through the SqlConnection object. Answer D is incorrect because you need to use Windows authentication instead of SQL Server authentication.

Question 29

The correct answers are B and C. To return a single value from the database, you should use the ExecuteScalar() method of the OleDbCommand object. The ExecuteScalar() method executes the query and retrieves the first column of the first row of the result set. You should always use stored procedures rather than the ad hoc SQL statements for speedy delivery. Answer A is incorrect because it uses a SQL query rather than the stored procedure. Answers D and E are incorrect because these solutions involve extra overhead when only a single value needs to be returned from the database.

Question 30

The correct answer is D. The controls already contain all the necessary property settings to transfer the data from the ListBox control to the TextBox control. However, you must call the DataBind method to actually perform the transfer. Answer A is incorrect because you want to bind the value with a text box and therefore you should call the DataBind() method on the TextBox control instead of the ListBox control. Answers B and C are incorrect because they do not present a solution that binds the value of the TextBox control.

Question 31

The correct answer is C. The best place to display the data underlined is when the sales amount is data bound with the control and before it is rendered. The ItemDataBound event is generated when an item is data bound, and it always occurs before it is rendered for display. The ItemDataBound event passes a DataGridItemEventArgs object to the event handler containing the details about the item that is data bound. Answer A is incorrect because the ItemCreated event is generated when an item is created in the DataGrid control. Answer B is incorrect because the ItemCommand event is generated when any of the buttons are clicked in the DataGrid control. Answer D is incorrect because the DataBinding event is generated when the DataGrid control binds to the data source rather than when individual items are data bound to the data in the data source.

Question 32

The correct answer is C. You have to bind the text box control with a single column of data in the data source control. You have already set the data source and the data member to bind. Therefore, you specify the row to bind using the Container.DataItem and then specify the column to bind. Answer A is incorrect because you have already set the DataSource and DataMember properties; now, you just have to bind to the specific column in the data. Answers B and D are incorrect because SelectedItemTemplate applies only to the selected row in the DataList control.

Question 33

The correct answer is B. You should use the XslTransform object to transform XML data using an XSLT style sheet. Answer A is incorrect because the XPathNavigator object enables you to explore the structure of the XML file. Answer C is incorrect because the XmlSchema object provides the schema definition. Answer D is incorrect because the XmlNode object represents a single node in the document.

Question 34

The correct answers are B and D. Either of these options can generate proxy classes for use in a client application. Answer A is incorrect because the .NET WebService Studio tool is used to invoke a Web service for testing. Answer C is incorrect because the Web Services Discovery Tool can locate files related to a Web service, but it does not generate any proxy classes.

Question 35

The correct answer is C. When the dir attribute is set to rtl , the horizontal alignment of the control's elements is reversed . Answer A is incorrect because you need to make minimal changes. Answers B and D are incorrect because there is no rtl attribute.

Question 36

The correct answer is B. The ADO library and other components developed with Microsoft Visual Basic 6.0 use single-threaded apartment (STA) as their threading model. By setting the AspCompat attribute to true , the .NET Framework allows the page to call STA components. Answer A is incorrect because STA COM components can be directly used only from ASP.NET pages and not from the compiled .NET assemblies. Answer C is incorrect because the Language attribute should be set to any .NET-supported language, such as C# and VB. Answer D is incorrect because, if you convert the STA component to an assembly using the Type Library Importer tool, your application can suffer from poor performance and possible deadlocks.

Question 37

The correct answer is B. Using the Type Library Importer tool ( tlbimp.exe ) enables you to generate an RCW assembly. To place the RCW assembly in the GAC so that it can be shared by all projects on the computer, you need to sign the assembly using the tlbimp.exe tool. Answers A and E are incorrect because you need to use the component in more than one project. Answer C is incorrect because you also need to sign the RCW assembly while generating it from the Type Library Importer tool. Answer D is incorrect because a Primary Interop Assembly is used for code from other vendors , not for your own code.

Question 38

The correct answer is C. To make the demo page more accessible, you should ensure that you supply all graphics with an alt attribute that conveys the important information about the image. The alt text information is displayed in place of the image when the image is being downloaded, the image is unavailable, the graphics are turned off in the browser, or the browser doesn't support images. Answer A is incorrect because PNG graphics are widely supported. Answer B is incorrect because providing the short key for the graphics is not as important as providing the alt attribute for the image. Answer D is incorrect because the AlternateText property is rendered to the browser as an alt attribute, unlike the ToolTip property.

Question 39

The correct answer is B. You can step into a stored procedure execution directly from within Visual Studio .NET. Answer A is incorrect because the Tools, Debug Processes menu item is useful for debugging running processes ”not the stored procedures. Answer C is incorrect because this option takes more time and effort, and the question requires minimal effort and time. Answer D is incorrect because the Debug.WriteLine() method cannot directly access the stored procedure values.

Question 40

The correct answers are A and D. The Debug and Trace classes share the same Listeners collection. Therefore, you should add a listener object either to the Trace.Listeners collection or to the Debug.Listeners collection. Answer B is incorrect because this solution generates double entries in the event log. Answer C is incorrect because the newly created listener object is not attached to the Listeners collection of the Trace and Debug classes.

Question 41

The correct answer is D. A conditional breakpoint lets you pause your code only when a particular condition is true. In this case, you can use that capability to break into the code when the variable has the value of 117 . Answers A, B, and C (Locals window, Output window, and Immediate window) are incorrect because they do not work conditionally.

Question 42

The correct answer is C. Breakpoints are invoked only when the project's configuration is in Debug mode. Answer A is incorrect because the Exceptions dialog box is used to configure the breakpoint only in case of an exception. Answer B is incorrect because, when you place a breakpoint, it is enabled by default. Answer D is incorrect because the project's configuration should be Debug instead of Release for debugging to occur (for breakpoints to be executed).

Question 43

The correct answer is C. The TraceContext class is responsible for providing detailed timing and other information in the browser window when you activate ASP.NET tracing. Answers A and B are incorrect because the Debug and Trace classes can be used to display messages about a program's execution but they can't provide detailed timing and other information about a program's execution. Answer D is incorrect because the Page class cannot provide timing information for the events on the Web page.

Question 44

The correct answer is D. To enable tracing for a particular page, you should set the Trace attribute of the Page directive to true . Answers A and B are incorrect because the <trace> element in the web.config file enables or disables tracing for all the Web pages of the application rather than just a single page. Answer C is incorrect because the enabled attribute takes a Boolean value rather than the name of the Web page. Answer E is incorrect because it disables tracing for the Web page.

Question 45

The correct answers are A and E. You need to sign a shared assembly with the strong name and then install the assembly in the Global Assembly cache. Answer B is incorrect because you use sn.exe instead of signcode.exe to sign an assembly with a strong name. Answer C is incorrect because the Windows system directory does not allow multiple versions of an assembly to be maintained. Answer D is incorrect because an assembly that needs to be shared by multiple applications should be stored in a common place, such as the GAC, rather than the bin directory of the Web application. Further, multiple versions of the assembly can be placed only in the GAC.

Question 46

The correct answer is C. Because the components are being used between several games published by your company, they are good candidates to be placed in the GAC of the target machine. However, before a component can be placed in the GAC, it must be signed using a Strong Name Tool ( sn.exe ). Your company is also deploying software over the Internet, so you should digitally sign your code with a software publisher's certificate obtained by a respected certification authority. After you obtain the certificate, you can use signcode.exe to sign your component. When you are using both sn.exe and signcode.exe with your assembly, you should always use sn.exe before using signcode.exe . Answers A and B are incorrect because you need to use both tools instead of just one of them. Answer D is incorrect because sn.exe should be used before signcode.exe .

Question 47

The correct answer is C. The applications always bind to the assemblies with which they are compiled. Therefore, if you want to execute a new version of the assembly, you either should recompile the application with the new version of the assembly or should modify the application configuration file to redirect to a new version of the assembly. Answers A and B are incorrect because the application will still request the old version of the assembly. Answer D is incorrect because applications will not be requested to choose a particular version of the assembly; instead the applications themselves will request the CLR to locate a specific assembly.

Question 48

The correct answer is D. The Merge Module projects enable you to create reusable setup components by packaging together all the required files, resources, Registry entries, and setup logic necessary to install a component. Answer A is incorrect because the Cab project creates a cabinet file for downloading from a Web browser. Answer B is incorrect because the Setup project creates an installer for a Web application. Answer C is incorrect because the Web Setup project creates an installer for a Web application. Answer E is incorrect because the Primary Interop Assembly is used for packaging legacy components.

Question 49

The correct answer is A. You can use the Custom Actions Editor to take custom actions such as database installation during the application setup. If you have an installer class or program that can create a database, you must override the Install() method of the base class and you must add the installer program to the Install node of the Custom Actions Editor. Answer B is incorrect because the Launch Conditions Editor is used to specify the prerequisite conditions that must be met to successfully run an installation. Consequently, it cannot be used to execute custom actions. Answer C is incorrect because the File System Editor only provides a mapping of the file system on the target machine and enables you to place files or folders on specific locations on the target machine. However, the File System Editor cannot be used to execute code to create the database. Answer D is incorrect because the User Interface Editor enables you to customize the user interface displayed during the installation process.

Question 50

The correct answer is E. When you enable impersonation by providing a name and password, any authenticated user takes on the credentials of the specified account for purposes of authorizing resources. Answer A is incorrect because the name and password ASP.NET uses to authorize resources are already defined by the <identity> element. Answer B is incorrect because the ASPNET account is used by ASP.NET for requests if impersonation is enabled and ASP.NET runs under a low-privilege account. Answer C is incorrect because the SYSTEM account is used by ASP.NET for requests if impersonation is enabled and ASP.NET runs under a high-privilege account. Answer D is incorrect because the IUSR_ ComputerName account, the identity of the IIS, is used by ASP.NET to make requests if the application allows anonymous access.

Question 51

The correct answer is D. You can store your custom settings in the <appSettings> element of the application configuration file. The .NET Framework provides the AppSettings property of the System. Configuration.ConfigurationSettings class to access the value of the custom key added to the <appSettings> element. Answer A is incorrect because asking the user to modify the Windows Registry can have undesirable effects. Answers B and C are incorrect because they involve writing additional code.

Question 52

The correct answer is A. Passport authentication enables users to be authenticated with a strong identity using any browser or version. Answer B is incorrect because Basic IIS authentication does not securely encrypt passwords. Answers C and D are incorrect because Digest and Windows-integrated authentication require Internet Explorer as the browser.

Question 53

The correct answers are A and C. You should deny all unauthenticated users with the ? wild character at the application level such that only authenticated users can access the application. In the web.config file of the Accounting directory, you should allow only members of the Accounting role and deny all other users (authenticated as well as unauthenticated) with the * wild character. Answer B is incorrect because you should disallow all unauthenticated users. The roles attribute should not contain wild card characters ; it should contain only the names of the Windows roles separated by commas. Answer D is incorrect because the <deny> element denies only unauthenticated users and provides access to the authenticated users.

Question 54

The correct answers are A and C. These code segments both allow access to the user if he belongs to either the Admins or Faculty role. Answer B is incorrect because it allows access only for those users who are in both the Admins and Faculty roles. Answer D is incorrect because, to give access to users in the Faculty role, you must call the permCheckFaculty.Demand() method.

Question 55

The correct answer is D. The OnChange() method invokes the Changed event to notify all registered objects about the event. If the Changed object is null , no delegate objects have been registered with this event. On the other hand, if the Changed object is not null , the call to the Changed event invokes the registered event handlers. Answers A, B, and C are incorrect because the name of the event is Changed rather than ChangedEventHandler .

Question 56

The correct answer is B. The composite control can easily encapsulate multiple Label controls into a single control. Because it's a custom control, it can be installed into the GAC and shared by multiple applications. Answer A is incorrect because the custom control needs to be used in multiple applications. If you create a Web user control, the user control files need to be included in each application. Answer C is incorrect because the control consists of multiple Label controls. Answer D is incorrect because your control needs to combine existing Web server controls and the WebControl class is used to create Web controls from scratch.

Question 57

The correct answer is C. Web user controls are the best way to reuse common user interface functionality in a Web application. Web user controls are easy to create, just like ASPX pages, and they inherit from the System.Web.UI.UserControl class. They can be easily dragged from Solution Explorer into the Web form. Answer A is incorrect because Web custom controls are precompiled and are best suited for creating custom controls to be used by multiple applications. Answer B is incorrect because using the Component class to create reusable visual components requires additional programming and is therefore better suited for creating nonvisual components. Answer D is incorrect because a Web form cannot be placed inside another Web form.

Question 58

The correct answer is D. Because this control is an extension of the Label control, it's easiest to create it by subclassing the existing Label control. Answer A is incorrect because a Web user control cannot be added to the Visual Studio .NET toolbox. Answer B is incorrect because composite controls contain more than one control. Answer C is incorrect because, if you derive from the WebControl class, you have to write more code.

Question 59

The correct answer is A. The Register directive is used to register a Web user control within an ASP.NET Web form. To register a Web user control, you need to specify three attributes: TagPrefix to provide an alias to a namespace to which the user control belongs, TagName to provide an alias to the user control, and Src to provide the path to the user control. Answers B and D are incorrect because the Control directive is used to define user-control-specific attributes in the user control file ( .ascx ). Answer C is incorrect because the Namespace attribute is used to associate with the tag prefix and is not a required attribute to register a user control.

Question 60

The correct answer is B. You should override the CreateChildControls() method to create the new controls the composite control will contain. This method is automatically called by ASP.NET when the control is supposed to be rendered. Answers A and C are incorrect because they are not defined as virtual methods and cannot be overridden to create child controls. Answer D is incorrect because the Render() method is overridden to provide the complete rendering of a Web control; it is used when you are designing a Web custom control from scratch rather than by combining existing controls.



MCAD Developing and Implementing Web Applications with Visual C#. NET and Visual Studio. NET (Exam [... ]am 2)
MCAD Developing and Implementing Web Applications with Visual C#. NET and Visual Studio. NET (Exam [... ]am 2)
ISBN: 789729016
EAN: N/A
Year: 2005
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net