How to set custom error page in SharePoint 2013/2010

Place the custom error page at
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\
TEMPLATE\LAYOUTS\1033"

Code :- 

namespace UpdateErrorPage
{
   class Program
   {
      static void Main(string[] args)
      {
           using (SPSite site = new SPSite("http://siteUrl",SPUserToken.SystemAccount))
           {
              SPWebApplication webApp = site.WebApplication;
              webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, "/_layouts/15/1033/customerror.html"); 
              webApp.Update();

              Console.Out.WriteLine(webApp.GetMappedPage(SPWebApplication.SPCustomPage.Error));
            
              //webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, null); //Reset Custom Error Page
              //webApp.Update();

              Console.Out.WriteLine("Press any key...");
              Console.ReadKey();
           }
       }
    }
}


Custom Error



Posted in SharePoint | Tagged , , , , , , , , , | Leave a comment

Custom Error Page in SharePoint 2013/2010

Open Web.Config file for your web application.

For Custom Error – I

change in web config tags

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" 
         TotalFileDependencies="250" AllowPageLevelTrace="true">

<customErrors mode="On" />

Error III

For Custom Error – II

change in web config tags

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" 
         TotalFileDependencies="250" AllowPageLevelTrace="false">
<customErrors mode="RemoteOnly" />

Error II

Shows Error Detail on Yellow Screen

For Custom Error – III

change in web config tags

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" 
         TotalFileDependencies="250" AllowPageLevelTrace="false">
<customErrors mode="On" />
Error I

Does Not Shows Error Detail on Yellow Screen

 

Posted in SharePoint | Tagged , , , , , , , , , | Leave a comment

How to add Favicon Icon on SharePoint Master Page – SharePoint 2013 Site

<head runat="server">

<!--SPM:<SharePoint:SPShortcutIcon runat="server" 
    IconUrl="/_layouts/15/images/favicon.ico?rev=23"/>-->

</head>

Posted in SharePoint | Tagged , , , , , , , | Leave a comment

How to get current user id and name in Sharepoint 2013 using Ecma Script

 

 var userid;
 function GetUserDetails() {
 
      clientContext = new SP.ClientContext.get_current();
      var oWeb = clientContext.get_web();
      currentUser = oWeb.get_currentUser();
      clientContext.load(currentUser);
      clientContext.executeQueryAsync(function () {
            userid = currentUser.get_id();
            usertitle = currentUser.get_title();
      }, function (error) {
            alert('Request failed: ');
      });

 }
Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

How to run ecma script on Page Load – SP Execute or



SP.SOD.executeFunc("sp.js", "SP.ClientContext", FunctionName);


function FunctionName(){

}

Posted in SharePoint | Tagged , , , , , , , , | Leave a comment

How to get logged in user image in SharePoint 2013 (MySite)

$.ajax({
     url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager"+
      "/GetMyProperties?$select=PictureUrl,DisplayName,AccountName",
     type: "GET",
     contentType: "application/json;odata=verbose",
     headers: { "accept": "application/json;odata=verbose" },
     async: false,
     success: function (data) {
             var pic = data.d.PictureUrl;
             var member = data.d.DisplayName;
             if (pic) {
                  $("#userName").text(member);
                  $("#paduserName").text(member);
                  $(".imageicon").attr("src",pic.Url);
            }
            else {
                 $("#userName").text(member);
                 $("#paduserName").text(member);
                 $(".imageicon").attr("src", "/SiteAssets/profile-icon.png")
            }
      }, 
      error: function (jqxr, errorCode, errorThrown) {
           console.log(jqxr.responseText);
      }
});
Posted in Uncategorized | Tagged , , , , , , , , | Leave a comment

Determine a Varchar field containing any numeric data

Select * From [TableName] Where [ColumnName] Like '%[0-9]%'
Posted in WildCard Search | Leave a comment