Which code segment should you add at line 05?

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?

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?

A.
properties.Cancel = false;

B.
properties.Cancel = true;

C.
properties.Status = SPEventReceiverStatus.Continue;

D.
return;

Explanation:
MNEMONIC RULE: “prevent from adding = cancel the event”

SPItemEventProperties.Cancel indicates whether to cancel the event

SPItemEventProperties Class
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventproperties.aspx



Leave a Reply 0

Your email address will not be published. Required fields are marked *