0

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.

3 Answers 3

0

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.

1
  • Thank you. I'm going to give the webpart method a try. it was smart ;)
    – Reza
    Commented Oct 3, 2012 at 11:53
1

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

2
  • Thank you. unfortunately i have to only mark one answer :(
    – Reza
    Commented Oct 3, 2012 at 12:21
  • main focus is to help you and learn, not to get points :P Commented Oct 3, 2012 at 13:03
0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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