Posts

Documentation of C# Code with SandCastle and Visual Studio 2010

Image
In this post I'll show you, how you can create a documention of your code. In the past ndoc was the tool to create code docus but the project seems to be dead. Therefore we use SandCastle, a freeware tool, that is also used by Microsoft to create Code-Documentations. Here is the reference of the comments within visual studio: http://msdn.microsoft.com/en-us/library/b2s063f7.aspx http://msdn.microsoft.com/en-us/magazine/cc302121.aspx First of all you need to install these things in the given order. Download and install SandCastle  http://sandcastle.codeplex.com/releases/view/47665 Download and install SandCastle Help File Builder (shfb). This is a gui for SandBox. Sandbox is mostly a command line driven tool, with a poor gui. This tool helps to create the documentation easier.  http://shfb.codeplex.com/releases/view/40105 If you want to create MS specific .chm (Compiled Html Help) files, download and install htmphelp.exe. http://www.microsoft.com/downloads/en/d...

HttpModule to check the performance of a (sharepoint) site

Image
I want to share the code of a http module I made for checking the performance of the backend site creation process. The result indicates if the site will break down when its launched and used by tausends of people. You can leave this module in your solution and activate it everytime you have to check the performance of a webpart or control. The module is simply activated by inserting an entry in the web.config. When you type perf=1 in the querystring (ex. http://mydomain.com/pages/default.aspx?perf=1) than a little yellow div will appear on the upper left corner, that displays the information. Performance of the backend process First we create a new class and implent the IHttpModule interface. We implement the init method, which is the starting point.There we have to create two delegates, that process the request. In an other class we implement the PerformanceFilter to manipulate the outputstream of the request. Here we read the stream an place a div with the information w...

RegularExpressionValidator autocomplete enter key problem in firefox

Image
I had some problems with the regularexpressionvalidator in firefox today. When I selected a value from the browsers autocomplete box, the field was validated to false. Autocomplete in firefox The validator throws an error The RegularExpressionValidator checks if the insert email address has the right format. If not than the validator outputs an error. In my case when I hit the enter key in the autocomplete box for the field, the validator message appeared, but when I hit the tab key all was fine. I digged a little into the javascript and found out that when I pressed Enter the value for the field to check in forefox was only the first character of the value entered. Therefore this was not a valid email address Then I found this post , that describes that this is a firefox bug The only solution for this problem seems to override the Microsoft core ValidateTextBoxOnKeyPress function somewhere in your page and check if the function is called in firefox. (I used here th...

Hooking into ASP Client Side Validation

The Problem: The ASP Validators are hard to style. The Validators only render a <span> with the error information. What if you want to display the complete div around the control to be red when an error occures? This is likely not possible with the standard asp validators. What you can do is o write a decorator in javascript. The function which displays the errormessages is the "ValidatorUpdateDisplay" method. 1: /** 2: * @requires JQuery 1.4.x 3: */ 4: var Biggy = {}; 5: 6: Biggy.Validator = { 7: /** 8: * Decorator for the ms validator update function 9: * 10: * @param {orig_fn} Function 11: * The function to decorate 12: * @return Function 13: * The decorated fucntion 14: */ 15: UpdateDisplayDecorator : function(orig_fn) { 16: return function(){ 17: var originalfunc = orig_fn.apply(this, arguments); 18: Biggy.Validator.UpdateParentDisplay( arguments[0] ); 19: return originalfunc; 20: };...

SharePoint 2010 Timer Job UpdateProgress

Image
SharePoint 2010 has updated some of its timer job features (see  http://pathikhrawal.wordpress.com/2010/08/21/enhancement-in-timer-jobs-in-sharepoint-2010/ ). Now SPJobDefinition offers an UpdateProgress Method, to show the status of the timer job in a status bar. UpdateProgress To check the status of a timer job go to "Central Administration > Monitoring > Check Job Status". Check Job Status link in the CA The following code snipplet  is an example of how you could use this method. The job reads a rss feed and uploads some pdf files into a document library. The progress bar is updated by each uploaded file. The snipplet is not complete, because of copyright. I commented out some regions but you can see how you could use the updateprogress function. public class PressListTimerJob : SPJobDefinition {   /// <summary>   /// We must persist the to have in the execute function   /// </summary>   [Persisted]   p...

Play a video from a asset library in SharePoint with the built-in Silverlight Media Player

Image
The Problem: You want to place a link into your SharePoint site which opens the Silverlight player in a lightbox and plays a video from a asset library. Solution: 1) Place the link within an other HTML element like a div, li or span and give this element an id. The link can be somewhere in this container, also in a deeper level - the link to the video must be serverrelative - the link can have a title. This can be used as Video title <div id="mediaplayer">    <a href="/site/listname/myvideo.wmv">Video</a>  ..  .. </div> Video link 2.) Place a script tag for the mediaplayer library and a custom script tag for our custom js. You must place it after or in the onload event, because when you use getElementById the element must exist in the DOM. <div id="mediaplayer">    <a href="/site/listname/myvideo.wmv">Open Video</a>  ..  .. </div> <script type="text/javascript...

Setting the default page layout in onet.xml (SharePoint 2010)

Image
In SharePoint 2010 you have the option to choose a default page layout when you create a page. Setting the default page When you create a new page, a dialog pops up where you enter the name of the site. You can configure your onet.xml and define the default page by the defaultpagelayout property in the publishing feature. Or you can set it programmatically as described in SharePoint Blues . There are also several other properties offered by the Publishing feature you can set: ChromeMasterUrl WelcomePageUrl PagesListUrl AvailableWebTemplates AvailablePageLayouts NewPageUrlToken AlternateCssUrl SimplePublishing VersioningOnPages / Documents / Images EnableModerationOnPages / Documents / Images EnableApprovalWorkflowOnPages / Documents / Images RequireCheckoutOnPages / Documents / Images EnableSchedulingOnPages /Documents / Images AllowSpacesInNewPageName Each property needs a different value. You can find a good listing of the properties a...