Posts

Showing posts from June, 2013

Differences between "Throw","Throw ex" and "Throw new Exception(...)" in .NET

The T hrow statement is used to inform about the occurrence of an exception when a program is executing. Exceptions contain a property named StackTrace . This string contains the name of the methods on the current call stack, apart from the file name and line number from where the exception was thrown for each method. There are 3 different ways to use the Throw statement: Throw Ex:   The original stack trace will be overwritten with a new stack trace that starts from the throwing method. Throw:   Preserves the original stack trace information because rethrows the original exception. Throw new Exception(...): Keeps original stack trace and adds aditional details.        Example: class Maths {     static void Main(string[] args)     {         try         {             MethodX();         }         catch (Exception ex)         {             // Throw Ex  - Method X stack trace (Method Y has been overridden)             //Exception: System.DivideByZeroException: Attem

How to auto save a browser enabled info path form every X minutes in Sharepoint 2007, 2010 and 2013

Info Path forms can be saved automatically every X minutes by updating the FormServer.aspx file. This update will avoid for users to lose their information when the session has expired and they forgot to save the form. The following code add some conditions so only the forms within a specific site and form view will be saved . I recommend you to copy the FormServer.aspx file before start with the changes to facilitate the file recovery if it fails. Update the FormServer.aspx file using a text editor as following:   If you are using SharePoint 2007: Include before the   </head>  tag    the following: < script language ="javascript" type ="text/javascript" > var timer_is_on = 0; var t; function doTimer() { clearTimeout(t); if (document.URL.indexOf( "SiteName" ) != -1) if (g_objCurrentFormData[9] != "FormViewToExclude"  && PostbackBody.intPostbacksInProgress == 0) if (!timer_is_on) { timer_is_on