Posts

_spPageContextInfo not found on the page

Add the following code to the page : <!DOCTYPE html> <%@ Page language="C#" %> <%@ Register Tagprefix="SharePoint"      Namespace="Microsoft.SharePoint.WebControls"      Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <html> <head> </head> <body>     <form runat="server">         <SharePoint:FormDigest ID="FormDigest1" runat="server"></SharePoint:FormDigest>     </form> </body> </html> You need to add the following code in case of JSOM: <!DOCTYPE html> <%@ Page language = "C#" %> <%@ Register Tagprefix = "SharePoint"       Namespace = "Microsoft.SharePoint.WebControls"       Assembly = "M

Create Responsive Circle

About Let’s see how to create a responsive circle with use of DIV tag in HTML CSS First we need to write some css for the circle: .circle {             margin-left : auto ;             margin-right : auto ;             border-radius : 50% ;             width : 100% ;             position : relative ;             border : 3px solid #D21009 ;             background-color : #d9534f ;         }         .circle:before {             content : "" ;             display : block ;             padding-top : 100% ;         }         .circle-inner {             position : absolute ;             top : 0 ;             left : 0 ;             bottom : 0 ;             right : 0 ;             text-align : center ;         }         .circle-text {             margin : auto ;             position : absolute ;             top : 0 ;             left : 0 ;             bottom : 0 ;             right : 0 ;           

Error occurred in deployment step 'Install app for SharePoint': Sideloading of apps is not enabled on this site.

I was trying to create SharePoint apps using Visual Studio 2013 & when I tryied to deploy it was showing me an error : The following feature need to be enabled : Display Name: EnableAppSideLoading Id: ae3a1339-61f5-4f8f-81a7-abd2da956a7d Compatibility Level: 15 To enable sideloading feature, use the following PowerShell commands:     $site = Get-SPSite "http://your.site.url" $sideLoadingId = new-object System.Guid "ae3a1339-61f5-4f8f-81a7-abd2da956a7d" $site.Features.Add($sideLoadingId)

Log error in a separate file

You can log your applications errors in separate text file. Use this code public static void WriteException(string msg)         {             try             {                 SPSecurity.RunWithElevatedPrivileges(delegate()                 {                     string LogFile = SPUtility.GetVersionedGenericSetupPath("LOGS",15) + "\\SPErrorLog-" + DateTime.Today.ToString("MM-dd-yyyy") + ".txt";                     StringBuilder sMessage = new StringBuilder();                     msg = msg.Replace("<b>", "");                     msg = msg.Replace("</b>", "");                     msg = msg.Replace("<HR/>", "");                     sMessage.AppendLine("--------------------------------------------------------------------------------------------------------------------------------------------");                     sMessage.AppendLine(msg);                     if (!

Get error with details

You can log error with all details you want. Here is the example. You need to just pass the exception object & it will return you the whole error details which will be very helpful.   public static string GetErrorInfo(Exception ex)         {             StringBuilder errorRows = new StringBuilder();             StackTrace stackTrace = new StackTrace(ex, true);             StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);             MethodBase methodBase = null;             try             {                 methodBase = stackFrame.GetMethod();             }             catch { }             errorRows.AppendLine("<b>Server         : </b>" + System.Environment.MachineName + "<HR/>");             errorRows.AppendLine("<b>Date Time         : </b>" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "<HR/>");             try             {                 errorRows.AppendLine("&l