SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that it is possible to write an event receiver to check the constraint but then how can I show a notification / message to the user?

Thanks for sharing your experience and knowledge.

share|improve this question
up vote 0 down vote accepted

You will have to use SPEventPropertiesBase.RedirectUrl and redirect to a different url to show the error. You can then make a custom way to display the error, possibly using a querystring or some other method.

You can't use the JavaScript SP.UI.Notify.addNotification directly but maybe you can make a webpart that picks up custom notifications another way.

share|improve this answer
Thank you. I'm going to give the webpart method a try. it was smart ;) – Reza Oct 3 '12 at 11:53

Best option as far as I know

Just create an event receiver for add Item which checks list item every time any item is added and once list items get above limit you can deny user from adding any more items.

However you can look at this question for redirecting in event receiver

share|improve this answer
Thank you. unfortunately i have to only mark one answer :( – Reza Oct 3 '12 at 12:21
main focus is to help you and learn, not to get points :P – Mathematics Oct 3 '12 at 13:03

I believe if the constrains evaluate to false, you will cancel that event. If that is the case then you can use the below code:

    properties.Cancel = true; 
    properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl; 
    properties.RedirectUrl = "/_layouts/EventReceiverProject1/CustomErrorPage.aspx?Error=" + errorMessage; 

You can find the complete code here

Hope this helps

share|improve this answer
Thank you. It's my secound candidate. – Reza Oct 3 '12 at 11:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.