Home > Articles > Certification > Microsoft Certification

This chapter is from the book

Exam Prep Questions

Question 1

Your company has recently decided to upgrade its supplier evaluation system from ASP to ASP.NET. You want to convert old ASP pages to Web forms as quickly as possible. You have noticed that you can keep the existing user interface but want to move the business logic to code-behind files. Which of the following approaches provides the smoothest migration path?

  1. Continue to use HTML controls on ASP.NET Web forms. In the code-behind files, rewrite all business logic using C#.

  2. Apply the runat="server" attribute to all HTML controls. In the code-behind files, rewrite all business logic using C#.

  3. Use ASP.NET Web server controls instead of HTML controls. In the code-behind files, rewrite all business logic using C#.

  4. Continue to use HTML controls for labels and text boxes but convert all Button controls to Web server controls. In the code-behind files, rewrite all business logic using C#.

Answer B is correct. Use of HTML server controls provides the easiest migration path for an existing HTML-based user interface. It does not take much effort to convert an HTML control to an HTML server control because you only need to add a runat="server" attribute to it. Answers A and D are incorrect because HTML controls are not directly available to the ASP.NET pages. Answer C is incorrect because ASP.NET Web server controls do not map one-to-one with HTML controls and will require additional conversion efforts.

Question 2

SurveyComm, Inc., is a marketing company that organizes surveys on behalf of large consumer goods companies. The surveys involve a large number of participants. SurveyComm recently decided to put its surveys online. You work as a Web developer for SurveyComm, and your responsibility is to design one of the online survey forms using ASP.NET. One of the questions in the survey form has a large number of options, and users can select multiple options as an answer to this question. You have used the CheckBoxList Web server control to display the options. In the code, you want to get all the options selected by the user so that you can store them in a database. Which of the following techniques should you use?

  1. Use the SelectedItem property of the CheckBoxList control.

  2. Use the SelectedIndex property of the CheckBoxList control.

  3. Use the DataValueField property of the CheckBoxList control.

  4. Use the Items property of the CheckBoxList control.

Answer D is correct. You should use the Items property of the CheckBoxList control to iterate through the list items and then use the Selected property of the ListItem object to find out whether the item has been selected. Answers A and B are incorrect because the SelectedIndex and SelectedItem properties return only the index of the first selected item and the first selected item, respectively. Answer C is incorrect because DataValueField is the data source that provides the item value and is used for populating the contents of CheckBoxList.

Question 3

You want to create a client-side event handler for the click event of a Button Web server control. The client-side event handler is written in JavaScript and is executed by the Web browser. The name of the Button control is btnSubmit, and the name of the JavaScript event handler is GlowButton(). How should you accomplish this in your Web form?

  1. <input id="btnSubmit" Type="Submit" Runat="Server"
        Value="Submit" onclick="GlowButton()"/>
  2. <input id="btnSubmit" Runat="Server"
        Value="Submit" onclick="GlowButton();"/>
  3. <asp:Button id="btnSubmit" Runat="Server"
          Value="Submit" onclick="GlowButton();"/>
  4. btnSubmit.Attributes.Add("onclick", "GlowButton();")

Answer D is correct. The preferred way to add client-side event handling code for Web server controls is via the Attributes property of the Web server controls. Answers A, B, and C are incorrect because these techniques interfere with the client-side event handling code generated by ASP.NET to perform automatic postback operations.

Question 4

You are using a DropDownList Web server control on a Web page that allows users to select a country name. Based on the user's selection of country, you want to display the drop-down list showing states in the selected country and several other country-specific fields. You don't want users to click a button to submit country information to the Web server. All your users have JavaScript-enabled browsers. You want to write a minimum of code; which of the following techniques would you use?

  1. Use an HTML server control instead of Web server controls.

  2. m B. Write client-side code in JavaScript to cause a postback when the user selects the country.

  3. m C. Set the AutoPostBack property to true.

  4. m D. Set the AutoEventWireup attribute to true.

Answer C is correct. You can specify a SelectedIndexChanged event to cause a form postback by setting the AutoPostBack property of the DropDownList Web server control to true. This technique automatically generates the required client-side code that causes the page postback when a user changes the selection. Answers A and B are incorrect because they require you to write additional code. Answer D is incorrect because the AutoEventWireup attribute is different from the AutoPostBack property and is used to specify whether ASP.NET will automatically call event handlers based on their names.

Question 5

You are creating a Web page that collects information about the various sports activities that interest your users. You want to display a sorted list of activities using a CheckBoxList, as shown in Figure 3.4. Which of the following ways should you choose to declare the CheckBoxList Web server control in your Web page?


Figure 3.4
How should you declare the CheckBoxList to display its items in the way shown here?

  1. <asp:CheckBoxList id="cblActivities" runat="server"
       RepeatColumns="2" RepeatDirection="Vertical"
       RepeatLayout="Table">
    ...
    </asp:CheckBoxList>
  2. <asp:CheckBoxList id="cblActivities" runat="server"
       RepeatColumns="2" RepeatDirection="Horizontal"
       RepeatLayout="Table">
    ...
    </asp:CheckBoxList>
  3. <asp:CheckBoxList id="cblActivities" runat="server"
       RepeatColumns="2" RepeatDirection="Vertical"
       RepeatLayout="Flow">
    ...
    </asp:CheckBoxList>
  4. <asp:CheckBoxList id="cblActivities" runat="server"
       RepeatColumns="2" RepeatDirection="Horizontal"
       RepeatLayout="Flow">
    ...
    </asp:CheckBoxList>

Answer A is correct. The given list is sorted, and you want to organize the elements vertically in a table of two columns. To achieve this, you should set the RepeatColumns property to 2, the RepeatDirection property to Vertical, and the RepeatLayout property to Table. Answers B and D are incorrect because the value of the RepeatDirection attribute should be set to Vertical rather than Horizontal. Answer C is incorrect because the value of the RepeatLayout attribute should be set to "Table" instead of "Flow".

Question 6

In a Web page, you are dynamically generating numerous Button controls. Each Button control is titled either Add or Update. You want to write a single event handler to handle events for all the Button controls. Which of the following options would you choose to ensure that you could take different actions when the Add or Update button is clicked?

  1. Write an event handler for the Click event. Use the event arguments passed to the event handler to determine whether an Add button or Update button was clicked, and take appropriate actions in the event handler.

  2. Write an event handler for the Command event. Use the event arguments passed to the event handler to determine whether an Add button or Update button was clicked, and take appropriate actions in the event handler.

  3. Set the CommandName property for each button to either Add or Update. Write an event handler for the Click event. Use the event arguments passed to the event handler to determine whether an Add button or Update button was clicked, and take appropriate actions in the event handler.

  4. Handle all the events in a page-level event handler such as the Load event.

Answer B is correct. The Command event is raised when the Button control is clicked. You can use the CommandEventArgs object to find the CommandName and CommandArguments associated with the button that initiated the event. Answers A and C are incorrect because the event arguments for the Click event do not give you enough information to determine the name of the button that was clicked. Answer D is incorrect because the Load event also does not have enough information available through its event arguments.

Question 7

You want to keep consistent formatting for all the Web forms in your application. To achieve this, you have created a CSS named styles.css and have linked it to all the Web pages. You have defined a style class named TextBoxStyle in styles.css to format text boxes onto the Web forms. Which of the following property settings would you use with the TextBox Web server control to use the TextBoxStyle style class?

  1. Class="TextBoxStyle"

  2. CssClass="TextBoxStyle"

  3. Class=".TextBoxStyle"

  4. CssClass=".TextBoxStyle"

Answer B is correct. When you want a Web server control to use a style class defined in a CSS file, you use the CssClass property of the Web server control. Answers A and C are incorrect because the Class property is used only with HTML server controls and not with Web server controls. Answer D is incorrect because, although the style itself might be defined as .TextBoxStyle, in the CSS file, you only need to specify the name (for example, TextBoxStyle) with the CssClass property.

Question 8

You are a Web developer working for a state-run agency and are creating a Web site for senior welfare programs. To register with the program, seniors must enter both their name and date of birth. The Web site should register a user only if her age is 65 years or more. You want to minimize the amount of validation code. How would you set up validation in the Web form to achieve this objective? (Select all that apply.)

  1. Use RequiredFieldValidator with the name.

  2. Use RequiredFieldValidator with the date of birth.

  3. Use CompareValidator with the date of birth.

  4. Use RangeValidator with the date of birth.

  5. Use CustomValidator with the date of birth.

Answers A, B, and C are correct. It is required that both the name and the date of birth be entered, so you must use the RequiredFieldValidator for both the fields. In addition to this, you need to compare the date of birth entered by the user with the current date to check whether she is 65 years or older. This can be easily done using the CompareValidator control by programmatically setting its ValueToCompare property. Answer D is incorrect because no fixed range has been specified for the age. Answer E is incorrect because it requires you to write additional validation code.

Question 9

You are developing a scheduling application for your company's intranet. You are using a Calendar control to enable easy and correct selection of dates. You want to mark holidays on the calendar so that users are aware of them while creating a schedule. For example, January 1 should be marked as New Year's Day. You want to display the description of the holiday in the same cell that displays the date. Which of the following calendar events would you use to achieve this?

  1. DayRender

  2. SelectionChanged

  3. VisibleMonthChanged

  4. Load

Answer A is correct. The DayRender event is raised when the Calendar control is rendered. The DayRender event is therefore the preferred place for writing additional messages along with a day. Answers B and C are incorrect because these events are fired on a user action only after the Calendar control has been displayed. Answer D is incorrect because the Load event is fired prior to the actual rendering of the control.

Question 10

You are designing a Web site that allows users to file their taxes online. Users log on to the Web site using their tax identification number and a personal identification number. You want to ensure that users do not include spaces with the tax identification number. You want to achieve this by writing the minimum amount of code. Which of the following validation controls would you choose?

  1. RequiredFieldValidator

  2. RangeValidator

  3. RegularExpressionValidator

  4. CustomValidator

Answer C is correct. The RegularExpressionValidator control is the best choice for performing validations that require you to match the control's value against a specific pattern. Answer A is incorrect because the RequiredFieldValidator only ensures whether a value is entered. Answer B is incorrect because no specific range of values has been specified. Answer D is incorrect because the CustomValidator control requires you to write additional code.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020