SharePoint4us

Explore the Experience in SharePoint 2013

Wednesday, October 15, 2014

Applying Site Page as default home page in SharePoint 2010 and 2013

Goto Site Actions-->Site Settings-->Look and Feel --->Welcome page

Change the Page url ...

All set now you are able to see the site page as  home page of your site .


  1. Programatically......Changing the Welcome  Page  

public static void ChangeWelcomePage(SPWeb rootWeb, string pageName)
{
    if (PublishingWeb.IsPublishingWeb(rootWeb))
    {
  PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(rootWeb);
  //Get the file name
  SPFile welcomeFile = rootWeb.GetFile(pageName);
  //Assign the new filename to the DefaultPage property
  pubWeb.DefaultPage = welcomeFile;
  //Update the Publishing Web.
  pubWeb.Update();
    }
}

Power Shell .


Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
################################################### code###################################################
$sourceWeb = $null try { $SiteUrl = "http://adigroup/myteamsite" $sourceWeb = Get-SPSite -identity $SiteUrl $oFolder = $sourceWeb.RootFolder; $oFolder.WelcomePage = "Pages/MyCustomPage.aspx"; $oFolder.Update();
} catch { write-host $_.exception
} finally { if($sourceWeb -ne $null){$sourceWeb.Dispose()}
}



Monday, October 13, 2014

Importance and Difference between SPListItem.Delete() method and SPListItem.Recycle() method.

If you delete a document in SharePoint using the UI, it’s being moved to the Recycle Bin, so that it can be restored if necessary. There are situations when you want to include deleting list items and documents in your custom solutions. The most commonly used approach I’ve seen is calling the SPListItem.Delete() method. While this does the job, and deletes the item, it deletes it permanently instead of moving to the Recycle Bin.

Looking carefully at the SPListItem class, you can find SPListItem.Recycle() method. It turns out that it’s exactly that method that you need to call in order to move a list item/document to the Recycle Bin instead of deleting it permanently.

In general moving items to the Recycle Bin instead deleting them permanently is what you should do in our custom solutions. It is standard SharePoint behavior and therefore something end users will expect of our solutions as well. You should perform the permanent deletion only if explicitly named in the requirements. Otherwise, let’s just stick to what SharePoint does to leverage the same User Experience.

Internally there isn’t much difference between the SPListItem.Delete and SPListItem.Recycle methods. Both call an internal SPListItem.Delete method with a different parameter which determines whether an item should be moved to the Recycle Bin or permanently deleted.

  1. public override void Delete()   
  2. {   
  3.       if (this.HasExternalDataSource)   
  4.       {   
  5.             SPUtility.ValidateFormDigest();   
  6.             string bdcid = (string) ((string) this.GetValue("BdcIdentity"));   
  7.             this.ParentList.DataSource.DeleteItem(bdcid);   
  8.       }   
  9.       else   
  10.       {   
  11.             this.DeleteCore(DeleteOp.Delete);   
  12.       }   
  13. }   
  1. public System.Guid Recycle()   
  2. {   
  3.       if (this.HasExternalDataSource)   
  4.       {   
  5.             SPExternalList.ThrowNotSupportedExceptionForMethod("Recycle", base.GetType());   
  6.       }   
  7.       return this.DeleteCore(DeleteOp.Recycle);   
  8. }   
  9.   

Monday, October 6, 2014

How to edit a page that has no “Edit Page” menu option in SharePoint( 2010 ,2013)



Some times we come across a situation where we can t find the edit button in ribbon even if we have full control .
 
 Solution :
Add the below parameter to your URL .
  ?ToolPaneView=2&pagemode=edit\

 sample URL :http://SharePointSite/pages/sample.aspx?ToolPaneView=2&pagemode=edit

Wednesday, August 27, 2014

Quering the listitems from without using Caml Builder setup

Quering the List Items from List and Doc Library   without using Caml Builder setup


Quering the listitems from  without using Caml Builder setup


Hi Guys ,

Generally, We do install cam builder setup in order to query the list items from list .

Now we can also retrieve the list  items without the  cam builder setup .

the only thing we need to do is to deploy the wsp and activate the feature like how we do regular wsp deployment

Get the Wsp from the link "http://www.u2u.be/Downloads/U2U.SharePoint.CQB2010.zip" (thanks to the one who made it for us )


After that open the list which u want to query, inside ribbon you can see the caml query icon , click on it explore the options available inside it .

Please go through it and  use this feature if it is helpful .







Friday, August 22, 2014

STSADM Commands and Power Shell Commands  for Deploying ,Installing activating feature


stsadm –o addsolution –filename “D:\Deploy\MySharePointSolution.wsp
We used the following command to deploy the solution once installed to a specific web application:
stsadm –o deploysolution –name MySharePointSolution.wsp –url http://myspwebappp –allowgacdeployment –immediate
If we would upgrade an existing solution, we would use the following:
stsadm –o upgradesolution –name MySharePointSolution.wsp –filename “D:\Deploy\MySharePointSolution.wsp” -immediate
And finally, we used the following commands to retract and delete a specific solution from the web application:
stsadm –o retractsolution –name MySharePointSolution.wsp –url http://myspwebapp –immediate
stsadm –o deletesolution –name MySharePointSolution.wsp
Now, let us see how we could do above operations with PowerShell. For this, we use the following PowerShell commands:
Add-SPSolutionD:\Deploy\MySharePointSolution.wsp
Install-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://myspwebapp –GACDeployment
If you would like to add the solution as sandboxed, you would use the Install-SPUserSolution command instead. To upgrade a solution, we specify which solution is to be updated and with which new solution file:
Update-SPSolution –Identity MySharePointSolution.wsp –LiteralPath “D:\Deploy\MySharePointSolution.wsp” –GacDeployment
To retract and remove a solution, we use the following commands:
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://myspwebapp
Remove-SPSolution–Identity MySharePointSolution.wsp

Working with features

Similarly, commands exist for working with features. The stsadm equivalents:
stsadm –o activatefeature –name MyFeatureName –url http://myspwebapp
stsadm –o deactivatefeature –name MyFeatureName –url http://myspwebapp
Needless to say, there are easy equivalents in PowerShell:
Enable-SPFeature –Identity MyFeatureNameOrGuid –url http://myspwebapp
Disable-SPFeature –Identity MyFeatureNameOrGuid –url http://myspwebapp

Tuesday, July 29, 2014



Delegate Controls in SharePoint 2010 and 2013

For More Information on SharePoint 2013 Delegate Controls
http://zimmergren.net/technical/sp-2013-some-new-delegatecontrol-additions-to-the-sharepoint-2013-master-pages

  Delegate Controls
   The Purpose of Delegate Controls is to Achieve the Customized functionality inside a master page without touching the Master Page


Generally, Whenever  we Create Master Page in SharePoint  it comes up with  Some out of  box delegate Controls .
These Delegate controls has got  some default functionality assigned by Microsoft guys
. So in case if we want to Override (means replacing the Default functionality with New Functionality ) the delgate Controls . through Visual Studio we can do this activity.

The below  Delegate Controls are by default available in Master Page .
  • GlobalNavigation.
  • SmallSearchInputBox.
  • QuickLaunchDataSource.
  • AdditionalPageHead.
   

1. Create new Empty Sharepoint Project
2. Create a new User Control and add some stuff in it.
3. Add Empty Elemnt.xml file

Empty Elemnt.xml : Inside the Element.XML File we are Intergrating the UserControl with Delgate Control in SharePoint Matser Page .
4. Deploy and See in Master Page
Not only we overide the Exsiting Delegate Controls we can also create new Delegate Controls .

  1. Sequence numbers. These numbers determine which control will be loaded in a delegate control. A delegate control can only have one control, unless AllowMultipleControls is set to true (See the second note just below). The control with the lowest sequence number will be the one rendered in the page.
  2. The AllowMultipleControls gives the developer the option to load several controls one after the other. This means that a custom delegate control will not replace an existing one and the order will be determined by the sequence number.

AdditionalPageHead


<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>

This delegate control allows the developer to add multiple html head lines. They will be rendered together with the ones SharePoint adds already there out of the box. For instance, we could load different .js libraries without modifying the existing MasterPage, or even build some logic behind our specific delegate control to load a JS library based on the logged user credentials.

GlobalNavigation

<SharePoint:DelegateControl runat="server" ControlId="GlobalNavigation"/>

This delegate control is used to add content at the top of the page, even on top of the “Site Actions” or “Welcome ID” Controls. SharePoint out of the box is using this delegate control to add some custom links, such as “My Network”, “My Content” and “My Profile” when we access our “My Site”.


GlobalSiteLink0

<SharePoint:DelegateControl runat="server" ID="GlobalDelegate0" ControlId="GlobalSiteLink0" />

This delegate control is used by SharePoint to place the Variations Menu. If we had multiple languages enabled in our site, we would be able to choose the appropriate language leveraged by the control “VariationsLabelMenu.ascx” placed within this delegate control.

GlobalSiteLink2

<SharePoint:DelegateControl ControlId="GlobalSiteLink2" ID="GlobalDelegate2" Scope="Farm" runat="server" />

SharePoint will use this delegate control to place a Social Delegate Control called “socialdata.ascx”. This control is the one in charge to render the links to “My Site” and “My Profile” when we expand the Welcome ID control.


PublishingConsole

<SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" Id="PublishingConsoleDelegate">

This control is the one rendering the dynamic publishing console. We should call it Server Ribbon when we are referring to SharePoint 2010. This Server Ribbon is the component that enables the end-user, and content editors, to work with SharePoint as a full WYSIWYG CMS. It renders all buttons, tabs, contextual tabs and contextual tab groups that appear while working with pages, documents or SharePoint content in general. It is not necessary now, with SharePoint 2010, to tweak this control in order to add buttons and/or tabs, you can use some other supported way to add them to the Ribbon (it could be another topic to blog about in the future).


GlobalSiteLink3

<SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" runat="server"/>

Renders two image links that are used to tag the current Page and open the SocialDataFrame.aspx page, allowing the user to manage the social tags and notes that are associated with the current Page.


SmallSearchInputBox

<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4"/>

This delegate control renders the small search box. This search box control leverages the search functionality as it’s been configured in Site Collection Administration, such as whether to show the search scopes etc… you could build your own Search Input Box component and replace it wherever your feature is activated.


TopNavigationDataSource & QuickLaunchDataSource

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
<SharePoint:DelegateControl runat="server" ControlId="QuickLaunchDataSource">

I covered these two delegate controls with my post about custom Top and QuickLaunch menus. Just to give you an intro to this subject I could say that with these delegate controls we can override the datasources that feed the top menu and quicklaunch menu. Therefore you can customize the links that appear dynamically or show/hide links based on any business requirement.

TreeViewAndDataSource

<SharePoint:DelegateControl runat="server" ControlId="TreeViewAndDataSource">

This delegate control wraps together a DataSource and a TreeView control. This control is rendering the content provided by the datasource. So, as you can see, this is a pretty self-enclosed and neat solution. If you dive a bit deeper into the FEATURES folder within the 14 hive you will see this delegate control is used not only at MasterPage level but also in several application pages, mainly the ones giving you the option to pick up files, such as upload.aspx or Picture Library pages.

SharePoint 2013 Delegate Controls
And now that SharePoint 2013 is available, you can find what's been added to the Delegate Controls collection here... http://www.helpmeonsharepoint.com/2012/07/sharepoint-2013-new-delegate-controls.html

Thursday, July 3, 2014

How to check Event Receiver is Attached or not ..to specific list/Library


Sometimes we come across a situation where we want to check event reciver is attached to list/library .
At that time if we run the below power Shell Script in Management Power Shell . then we can easily identify the event reciver attached to the list .




$web = Get-SPWeb "Server URL"
#$web=$site.OpenWeb();          
$spList = $web.Lists["List/Library Name"] 
$spList.EventReceivers | Select Name, Assembly, Type



Need to  Save the file As .ps1 and open Managemnet Power sheel as admin run the path