Posts

Showing posts from December, 2014

Programmatically Add Content By Query WebPart to Page

using ( SPLimitedWebPartManager webPartManager = SPContext . Current . Web . GetLimitedWebPartManager ( "SitePages/CRISP/Home.aspx" , System . Web . UI . WebControls . WebParts . PersonalizationScope . Shared )) {         ContentByQueryWebPart cqwp = new ContentByQueryWebPart ();         cqwp . ContentTypeBeginsWithId = "0x0101006F0A470EEB1140E7AA14F4CE8A50B54C0001CB1477F4DD432AA86DD56CC3887AF40902" ;         cqwp . WebUrl = web . ServerRelativeUrl ;         cqwp . MainXslLink = "/Style Library/XSL Style Sheets/ContentQueryMain.xsl" ;         cqwp . Title = "Recently Published" ;         webPartManager . AddWebPart ( cqwp , "Top" , 1 );         webPartManager . Web . Dispose (); }

Run timer job on a single content database in sharepoint

public override void Execute ( Guid contentDbId ) {     SPSite siteCollection = new SPSite ( mySiteCollectionUrl );     if ( siteCollection . ContentDatabase . Id . Equals ( contentDbId ))     {         // timer job code     } } or SPJobLockType.ContentDatabase

OOTB Workflows in sharepoint

#1: Approval #2: Collect Feedback #3: Collect Signatures #4: Publishing Approval #5: Three-State

SharePoint 2013 Branding Features

1. Design Packages 2. Device Channels 3. Image Renditions 4. Display Templates

The Context has expired and can no longer be used. (Exception from HRESULT: 0x80090317) in SharePoint 2013

After some analysis, found the root cause as the Time zone as suspected.    The fix for this would be, 1. Go to Central Administration. 2. Manage Web Application. 3. Select the Web application. 4. Go the General Settings. 

what is Event Cache table in sharepoint

Every Content database in SharePoint Contains an EventCache table that is the change log for objects contained in the database. Each row in this table is depicting a change in an object where columns usually contain information such as the date and time of a change, the type of object that was changed, the nature of the change, and a unique identifier for the object. EventCache table is important because it stores the list of site events for which users might have requested alerts.

modify site collection as read only in sharepoint

Site Collection Read-Only in SharePoint Option 1: Making Read-Only through Central Administration Go to Central Administration > Application Management > Configure quotas and locks In the appearing page, choose the site collection & select the option   Read-only . Option 2: Making Read-Only through PowerShell Set-SPSite -Identity "http://hp/sites/sc2? -LockState "ReadOnly" Set-SPSite -Identity "http://hp/sites/sc2? -LockState "Unlock" Option 3: Making Read-Only through Code SPSite site = new SPSite("http://hp/sites/sc2?); site.ReadOnly = true;

Create and delete taxonomy group from SOM in sharepoint

Create Taxonomy Group SPSite site = new SPSite( "http://win-5c3g1lanj3k:46908/" );                 TaxonomySession session = new TaxonomySession(site);                 TermStore termStore = session.TermStores[ "Managed Metadata Service" ];                 Group group = termStore.CreateGroup(TextBox1.Text);                 TermSet termSet = group.CreateTermSet(TextBox2.Text);                 Term term = termSet.CreateTerm(TextBox3.Text, 1033);                 term.SetDescription(TextBox4.Text, 1033);                 termStore.CommitAll();                 Label4.Text = TextBox1.Text + " - Taxonomy Group Created Successfully" ; Delete Taxonomy Group SPSite site = new SPSite( "http://win-5c3g1lanj3k:46908/" );                 TaxonomySession session = new TaxonomySession(site);                 TermStore termStore = session.TermStores[ "Managed Metadata Service" ];                 Group group = termStore.Groups[Text

Diference between SPSite and SPWeb

SPSite SPWeb It is a Site Collection including top level site. It is a specific website under Site Collection. It could be individual sub site or top level site. SPSite is container that contains a single SPWeb (ex: SPSite.RootWeb), Top level site is referred as root web. To return the current site collection use : SPSite site = SPContext.Current.Site To return the web site: SPWeb web = SPContext.Current.Web Few methods are  Dispose(), Close(), Delete(), GetChanges(), GetUrls() etc. Few methods are Delete(),Dispose(), GetList(), GetListFromUrl() etc.

Difference between Site Template and Site Definition

Site Template Site Definition provides the basic component and layout of a new site to be created in SharePoint Site definition is a blue print for a site. It is a collection of .XML, .ASPX, .master files which contains all the necessary components. A site template is based on the underlying site definition Site definition is the “Core” of a site. Extension of site template file is .stp Site template can be stored in a CAB based file and can be downloaded or uploaded to site collection as per user rights. Files are stored in Content Database. Files are stored on local disk, so it performs better.

Get client browser version and Os version in c# or vb

"User Agent: "  & Request.UserAgent &  " ::::: "  &  "Browser: "  & Request.Browser.Browser &  " ::::: "  &  "Version: "  & Request.Browser.Version &  " ::::: "  &  "MajorVersion: "  & Request.Browser.MajorVersion() &  " ::::: "  &  "MinorVersion: "  & Request.Browser.MinorVersion()

Use of SPDisco.aspx in sharepoint

SPDisco.aspx file is a directory of all web services available in SharePoint.This file contains names and locations of all web service endpoints which is available in SharePoint. If you are creating  custom web service in SharePoint then you must do an entry of endpoints in SPDisco.aspx file. Location of SPDsico.aspx file is:" C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI "

Feature stapling in sharepoint

Feature stapling is a concept by which a feature can be pin or staple to a site template. Let’s assume there is a company of computer assembling. There is a scenario that client told, there should be a list containing computer parts with price. They have few sites and subsites where they want to display this list. Also in future if a site will be created same list should be presented in this site. So you can understand the use of Feature stapling.

Get Mail ID from Active directory

SPUser object but if see we used EnsureUser method.   EnsureUser is predefined method it will check whether a user exist in the current site or not.    If the user does not exist in the current site it will add the user to current site.    SPFieldLookupValue, it’s predefined function.   It will grab the lookup ID and lookup value. In our example lookup value means user name “Sreehari, Inukoll” using (SPSite siteCollection = new SPSite(" http:// "))             {                 using (SPWeb web = siteCollection.RootWeb)                 {                     SPList lstPOCreation = web.Lists["listofspusers"];                     SPListItemCollection items = lstPOCreation.GetItems();                     foreach (SPListItem item in items)                     {                         SPUser to_user = web.EnsureUser(new SPFieldLookupValue(item["userid"].ToString()).LookupValue);                         item["email"