Posts

Showing posts from May, 2014

SharePoint - Logging to ULS in SharePoint 2010

Image
When developing custom components for SharePoint, be it simple or complex, it is a good practice to log all the activities made by the solution. It is of great help during debugging and maintaining the code. SharePoint 2010, via its object model, let's us access the diagnostic services and add custom messages to the log files.

Here is a quick example.

In this case we are trying to access a list named MyList, which does not exists in the site. So an exception will be thrown.

using (SPSite site = new SPSite("http://site/")) { using (SPWeb web = site.OpenWeb()) { try { SPList list = web.Lists["MyList"]; } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("My Category", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace); } } }
And here is what we get in the UL…

SharePoint - How to Create Hyperlinks to a Pop-Up Dialog

Image
Do you like those cool SharePoint 2010 shadowbox pop-up dialogs?

So do I, since it means less page navigation and general confusion for end-users. The problem is when you want to create your own custom hyperlinks from quick launch or throughout your own pages.

There are several blogs out there that show how to accomplish this using JavaScript snippets in CEWPs, etc. But there is actually a much easier way to do it using a built-in JavaScript feature of SharePoint.

Use this in your HTML

<a href="javascript:OpenPopUpPage('http://bing.com');">Test Link</a>

 Note: Obviously, replace the Bing URL with your own.