nerdexam
Microsoft

70-573 · Question #266

You have a SharePoint list named Announcements. You have an event receiver that contains the following code segment. (Line numbers are included for reference only.) 01 public override void…

The correct answer is B. properties.Cancel = true. MNEMONIC RULE: "prevent from adding = cancel the event" SPItemEventProperties.Cancel indicates whether to cancel the event SPItemEventProperties Class

Developing Business Logic

Question

You have a SharePoint list named Announcements. You have an event receiver that contains the following code segment. (Line numbers are included for reference only.) 01 public override void ItemAdding(SPItemEventProperties properties) 02 { 03 if (properties.ListItem["Title"].ToString().Contains("secret")) 04 { 05 06 } 07 } You need to prevent users from adding items that contain the word "secret" in the title to the list. Which code segment should you add at line 05?

Options

  • Aproperties.Cancel = false;
  • Bproperties.Cancel = true;
  • Cproperties.Status = SPEventReceiverStatus.Continue;
  • Dreturn;

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    77% (23)
  • C
    13% (4)
  • D
    7% (2)

Explanation

MNEMONIC RULE: "prevent from adding = cancel the event" SPItemEventProperties.Cancel indicates whether to cancel the event SPItemEventProperties Class

Topics

#event receiver#ItemAdding#Cancel property#list validation

Community Discussion

No community discussion yet for this question.

Full 70-573 Practice