With SharePoint 2010 , while cancelling an event (off course synchronous events end with ing ), you can also redirect users to your custom error page. This is quite helpful , but there is a small glitch. Once you are landed on the custom error page, there is no out of the box way to go back to the original form. This is important as you may want to go back to the original form in case you want to fix some data entries etc. One of the obvious reason that this is not provided is because as custom error pages are essentially SharePoint Application pages , the implementation is left on your side. Having said that , you still need some way out of this. Following is a quick workaround for this. I am assuming that you already have event receiver and a blank custom error page.If not its super easy to do so using Visual Studio 2010 and creating SharePoint 2010 Project of type Event Handler (I don’t show the steps to create the project here to make this post short and topic specific)
The project look like this . off course project name and custom error page will be different but that is not relevant)
In the application page (which will be used as a custom error page) I just added a single line inside Main content , as shown below.
For the event receiver , I have implemented ItemAdding event receiver for a custom list . The event is cancelled with redirection to a custom error page , this is shown in the code fragment below.You may want to adjust the folder and error page name accordingly.
At this point , if you deploy the project (F5 from Visual Studio 2010 would do) and then try to add a new item to the custom list , you will see the custom error page as shown below.
Now , lets address this issue of not going back to the original form. Add the following mark-up inside the custom error (application page).
Now re-deploy the solution (F5 from Visual Studio would do) again, and try to add new item into the custom list. This time you will see the custom error page with two links , namely “Go back to previous page” and other “Close” , this is shown in figure below.
Clicking “Close” link will close the dialog , while “Go back to previous page” link will revert back to previous page as shown below.
NOTE: Although this workaround works most of the time, do test it extensively before using it. Also , note that this post was based on SharePoint 2010 Beta , its most likely that the workaround will work in RTM but still there is no guarantee.
In SharePoint 2010, there are number of new events that you can override. One of them is WebAdding, interesting enough this event allows you to cancel the Web (of type SPWeb, confused with SharePoint terminology? see table at the end of the post) creation process. This is actually quite powerful, because you can perform validation based on complex business rules, and if required can even cancel the web creation process. But keep in mind that SharePoint 2010 provides two events related to web creation process, as discussed below.
· Web is being created, and this process fire up WebAdding. You can cancel the event and as a result web will not be created.
· Web is created. This is after SharePoint is done with provisioning all the required files for the Web. This can be captured by WeProvisioned event. However as web is already created, you cannot cancel the creation process.
When SharePoint is creating a web, you will not able to access all the items (e.g page themselves), so tasks like populating pages with content cannot be done inside the WebAdding event. For performing these tasks override WebProvisioned event. The reason why it’s important to understand this is because WebAdding event is basically fire on parent web, not the web which is being created.
See the image below.
So when you create the SubWeb1 the WebAdding will be fire on RootWeb .This raises a question will WebAdding event will fire when RootWeb is being created?
The answer is No, it will not fire because there is no parent web for it. In fact if you check for ParentWeb property on the RootWeb , it will always return null. Make sure if you are overriding WebAdding event, you carter for this case, this will help avoiding exceptions.
Sub web of type SPWeb. Each Site collection can have one or more sub web. There is special web called RootWeb this refers to top level web which act as a parent and cannot be deleted. Sometimes terms Sub sites or just Web is used instead of sub web.
Site collection of type SPSite, this is what contains the sub web (SPWeb). The word Site is mostly used while referring to site collection.
Web application of type SPWebApplication. Web application can contain multiple site collections.
SharePoint Saturday is coming to Arabia on 27th March 2010.! This is simply awesome news, following the excellent trend of SharePoint Saturday all around the world there will be number of sessions on SharePoint 2007/2010 with great speakers from all over the world. One of the key advantage of this event is , that as its online , so its accessibility is huge. I am also presenting a session (detail will be coming soon on this blog!).
So , let me give you a quick jump start.
Where do I register for the event?
What are the sessions and who is delivering them?
You can get the details on sessions and speakers here , just keep in mind as sessions are still in finalizing stage , they will be start appearing as soon as they are confirmed. So thanks for your patience in advance!.
What Time the event take place for me , as I am not located in Gulf?
Its ok , its an online event. Exact date and time duration of the event is Saturday, March 27, 2010 from 7:00 AM – 4:00 PM (GMT). If you are having difficultly mapping or convert the date and time to your country and time zone, use Time Zone Convertor web site , simple and excellent way to quickly get it done.
What I will need to attend the session?
In order to hear the presenters, you will need headphones or computer speakers. There will be no conference call dial-in phone numbers.
I am in , give me more updates now
SharePoint Arabia is both on Facebook and Twitter , follow them!
Time for a quick blog post to notify all of you that , the launch date for the Office 2010 & SharePoint 2010 is announced , its 12th May 2010. Stephen Elop , president of the MSFT Business Division will be delivering a keynote at 11 am EST , it will be great moment and should not be missed , make an entry to you calendar by downloading ics here.
Time really passes so quickly.I remember installing Technical Preview(not public) bits of SharePoint 2010 last July , then in Nov get the Beta (this is what is publically available to everyone) , and now working with RC (not public) . Honestly when I compare the overall experience (installation , documentation etc) to what we get for MOSS 2007 Beta its amazing how much work MSFT had done to improve in all of these areas. MSDN / TechNet are loaded with very helpful stuff from the day Beta is released and getting better since then, this include guides , samples , articles and videos etc. I really think SharePoint 2010 will bring new wave of productively to the consumers, kudos to the MSFT team for this!