Hi Ishai,
Thanks for you reply. Your answer was not what I was hopping but gives me an idea of a way to try and I do not give up until I try my last idea. I remember reading on internet a way to get the current http context adding the following lines in the initialization of the class: using System.Web; namespace SoftwareRegisterList { public class ItemEventReceiver : SPItemEventReceiver { HttpContext CurrentHttpContext; public ItemEventReceiver() { CurrentHttpContext = HttpContext.Current; } ... } Yes, but the HttpContext do no have any reference to the SPView. Then I check the SPContext and I found that has a ViewContext property that return a SPViewContext object that contain an View property that return an SPView object. Then, I tried to use the same code but changing the HttpContext to SPConext like this: public class SoftwareRegisterEventReceiverItemEventReceiver : SPItemEventReceiver { SPContext CurrentContext; public SoftwareRegisterEventReceiverItemEventReceiver() { CurrentContext = SPContext.Current; } And yes, I get the SP Current Context but for my desperation the ViewContext property is not instantiated. Then I saw that was a CurrenContext method in the SPItemEventReceiver class. But again no luck and here is my first question: Why is an overridden CurrentContext method created when you add an event handler if this method does not exist in the SPItemEventReceiver Class at all and then it will never fire? I suppose the answer is the TODO summary description on the top. :o) At this point I am running out ideas but I would like to ask if you or any in the news group has tried this path and what was the outcome. Best Regards, Javier Martinez ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ishai Sagi Sent: Monday, 24 November 2008 3:35 PM To: listserver@ozMOSS.com Subject: [OzMOSS] RE: Getting the current view of a list in the updating event handler. You cant. Even though the event is synchronous, you don't get a reference to the current context, which means you will not be able to tell. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martinez, Javier (Outsourcing) Sent: Monday, 24 November 2008 5:03 PM To: listserver@ozmoss.com Subject: [OzMOSS] Getting the current view of a list in the updating event handler. Hi All, I have been trying to figure out how to get the current view of a list in the updating event handler but no luck. My problem is that I want to know if the view is Standard or Grid and do different things depending on the view. Something like this: /// <summary> /// Synchronous before event that occurs when an existing item is changed, for example, when the user changes data in one or more fields. /// </summary> /// <param name="properties"> /// A Microsoft.SharePoint.SPItemEventProperties object that represents properties of the event handler. /// </param> public override void ItemUpdating(SPItemEventProperties properties) { if (string.IsNullOrEmpty((string)properties.AfterProperties["Person"]) == true) { if (string.IsNullOrEmpty((string)properties.AfterProperties["Return Date"]) == true) { if(GetCurrentViewType(properties.ListItem.ParentList).CompareTo("GRID") == 0) { properties.AfterProperties["Book out"] = 0; } else { properties.AfterProperties["Book out"] = false; } } } } public string GetCurrentViewType(SPList List) { foreach (SPView View in List.Views) { // This does not work when the List is embedded in a webPart if (View.Url.CompareTo(List.ParentWebUrl) == 0) { return View.Type; } } return "N/A"; } I have tried to use the parameters.ItemList.ParentList object with the GetView, Views and DefaultView properties but any of them return the view used in the current context. Any help will be appreciated. Regards, Javier This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com