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
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)- A3% (1)
- B77% (23)
- C13% (4)
- D7% (2)
Explanation
MNEMONIC RULE: "prevent from adding = cancel the event" SPItemEventProperties.Cancel indicates whether to cancel the event SPItemEventProperties Class
Topics
Community Discussion
No community discussion yet for this question.