Pages

Friday 18 September 2015

Allow anonymous access to SharePoint application pages



We can access the Application page in SharePoint anonymous site.

·         By default, the page is inherited from LayoutsPageBase. Change the inheritance from “LayoutsPageBase” to “UnsecuredLayoutsPageBase”.
·         Next, we need to override a property of the UnsecuredLayoutsPageBase, to allow the anonymous access. Be sure to change the ‘getter’ to return true

protected override bool AllowAnonymousAccess { get { return true; } }

Example :



Reference:


Wednesday 9 September 2015

Office 365 how to build and deploy a web part with sharepoint online



Prerequisites:

1. Visual Studio
2. SharePoint Site
3. Visual Studio 2010 Power Tools
4. Office 365 Site

Note: Please install Visual Studio 2010 Power Tools before starting

Please follow the below Procedure.
Step 1

Run Visual Studio as an Administrator

Step 2

Create a Project using “Empty SharePoint Project” Template

Step 3

Specify the local Share Point site Url(Not o365)

Step 4

Select “Deploy as Sandbox solution”option and click on Finish

Step 5

Now Add Visual Web part(Sandbox) Template

Step 6

Write your code as per the requirement

Step 7

Build the Solution and Test the functionality in Local Site.

Step 8

Package the solution by clicking on “Package” Option.
Right click on solution ->Package

Step 9

Now login into o365 Site as an Administrator

Step 10

click on the solution Gallery
Root site -> Site Actions -> Site Settings -> Galleries -> Solutions

Step 11

Click on Solutions

Step 12

Click on “Upload Solution” and browse the .wsp file that you have created in Visual Studio
take wsp from bin’s Debug/Release Folder of Solution.

Step 13

Click on “Activate” button

Step 14

Create Page and add the web part. Thats it.

Get list template using PowerShell

Sunday 10 May 2015

SharePoint configuration and content databases

http://sharepoint.stackexchange.com/questions/61584/sharepoint-configuration-and-content-databases

Monday 2 February 2015

Get all Wsp from SPFarm using PowerShell

(Get-SPFarm).Solutions | ForEach-Object{$var = "Folder Path" + "\" + $_.Name;$_.SolutionFile.SaveAs($var)}

Thursday 29 January 2015

Get SPGroup users in SharePoint programmatically

 SPGroup UserGroup = OWeb.Groups["User Group Name"];
 if (UserGroup.Users.Count > 0)
  {
     foreach (SPUser User in UserGroup.Users)
     {
        string UserName=User.LoginName;
     }
  }

Wednesday 28 January 2015

Adding and Deploying solution using powershell in SharePoint

Add Solution:

add-SPSolution "wsp file path"

Deploy Solution:

Install-SPSolution –Identity "example.wsp" –WebApplication "http://sp2013" -GACDeployment

Update Solution:

Update-SPSolution –Identity "example.wsp" –LiteralPath "Wsp path" –GACDeployment

Retract Solution:

Uninstall-SPSolution –Identity "Example.wsp" –WebApplication "http://sp2013"

Remove Solution:

Remove-SPSolution –Identity "Example.wsp"



Wednesday 21 January 2015

Wednesday 7 January 2015

Check current user in SPFieldUser collection

SPFieldUserValueCollection usercoll= new SPFieldUserValueCollection(oweb, item["usercoll"].ToString());
bool containuser=likedBy.Find(u => u.User.LoginName.ToString().Contains(SPContext.Current.Web.CurrentUser.LoginName))!= null ? true : false;