Posts

Showing posts from June, 2012

DataTable Sorting

DataView dv = new DataView (dtcoll); dv.Sort = "DisplayOrder" ; GrdCourses.DataSource = dtcoll; GrdCourses.DataBind();

How to update the People Picker column in SharePoint using Event Receiver

                   SPUser ouser = properties.Web.EnsureUser(User);                    SPFieldUserValueCollection value = new SPFieldUserValueCollection ();                    value.Add( new SPFieldUserValue (properties.Web, ouser.ID, ouser.Name));                    SPList olist = properties.Web.Lists[ "AssetMaster" ];                    SPListItem oitem = olist.Items.Add();                    oitem[ "UserColumn" ] = value;                    oitem.Update();

Schedule a task in Windows 7

http://windows.microsoft.com/en-us/windows7/Schedule-a-task

Creating Hierarchical Menus with a CustomAction in SharePoint

http://weblogs.asp.net/jan/archive/2008/05/08/creating-hierarchical-menus-with-a-customaction-in-sharepoint.aspx

What is PerformancePoint Services for SharePoint 2010?

http://blogs.msdn.com/b/performancepoint/archive/2009/10/20/what-is-performancepoint-services-for-sharepoint-2010.aspx

FBA Configuration in SharePoint 2010

http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/

Referential Integrity between SharePoint Lists

http://msdn.microsoft.com/en-us/sp2010devtrainingcourse_listsandschemalab_topic3.aspx

What is the Expansion of CAS ?

C ode A ccess S ecurity

Swap two numbers without using third variable

Num1=Num1+Num2; Num2=Num1-Num2; Num1=Num1-Num2;

Exporting Solutions packages (WSP files) with PowerShell

$dirName = "c:\Exported Solutions" Write-Host Exporting solutions to $dirName foreach ($solution in Get-SPSolution) {     $id = $Solution.SolutionID     $title = $Solution.Name     $filename = $Solution.SolutionFile.Name     Write-Host "Exporting ‘$title’ to …\$filename" -nonewline     try {         $solution.SolutionFile.SaveAs("$dirName\$filename")         Write-Host " – done" -foreground green     }     catch     {         Write-Host " – error : $_" -foreground red     } } More Info http://sharepintblog.com/2011/06/04/exporting-solutions-packages-wsp-with-powershell/

How-to Hide Columns In List/Libraries Views and Forms

Image
Navigate to the list or library which you need to hide the columns Under  General Settings , select  Advanced Settings Next to  Content Types , select  Yes  to  Allow management of content types Click  OK Back in the  Settings  page, you will now notice a heading for  Content Types Select the existing  Content Type  to edit it In the  Content Type  settings page, select the columns which you wish to hide. There are three options to choose from: Required (Must contain information) Optional (May contain information) Hidden (Will not appear in forms) Select Hidden to hide the column from the form Click OK when you are complete.

Downloading wsp from Central Admin

you can run the below script in powershell $farm = Get-SPFarm $file = $farm.Solutions.Item("Sample.wsp").SolutionFile $file.SaveAs("c:\Kannan\sample.wsp") The above cmdlet will take only particular wsp as you mentioned in cmdlet

SharePoint interview Questions

http://sharepointknowledgebase.blogspot.in/2011/08/sharepoint-interview-questions-and.html

Differences Between Sandboxed and Farm Solutions

Farm Solutions            Farm solutions, which are hosted in the IIS worker process (W3WP.exe), run code that can affect the whole farm. When you debug a SharePoint project whose Sandboxed Solution property is set to "farm solution," the system's IIS application pool recycles before SharePoint retracts or deploys the feature so as to release any files locked by the IIS worker process. Only the IIS application pool serving the SharePoint project's site URL is recycled. Sandboxed Solutions      Sandboxed solutions, which are hosted in the SharePoint user code solution worker process (SPUCWorkerProcess.exe), run code that can only affect the site collection of the solution. Because sandboxed solutions do not run in the IIS worker process, neither the IIS application pool nor the IIS server must restart. Visual Studio attaches the debugger to the SPUCWorkerProcess process that the SPUserCodeV4 service in SharePoint automatically triggers and controls. It is n

Reserved Querystring Parameters In SharePoint

Note : Its very important when naming QueryString parameter in your SharePoint Applications For further info click here  to read

How to Create Stored Procedure

CREATE PROCEDURE sp_myStoredProcedure    @myInput  int AS Select column1 From TableName Where column1= @myInput exec sp_myStoredProcedure 17876

Get All SubWebs using Client Object Model

 static string mainpath = "http://SiteURL";         static void Main(string[] args)         {             getSubWebs(mainpath);             Console.Read();         }         public static  void  getSubWebs(string path)         {                       try             {                 ClientContext clientContext = new ClientContext( path );                 Web oWebsite = clientContext.Web;                 clientContext.Load(oWebsite, website => website.Webs, website => website.Title);                 clientContext.ExecuteQuery();                 foreach (Web orWebsite in oWebsite.Webs)                 {                     string newpath = mainpath + orWebsite.ServerRelativeUrl;                     getSubWebs(newpath);                     Console.WriteLine(newpath + "\n" + orWebsite.Title );                 }             }             catch (Exception ex)             {                             }          

Creating a Custom Field Type for SharePoint 2010 (Email Validation Field)

Ref :  http://www.c-sharpcorner.com/uploadfile/Roji.Joy/creating-a-custom-field-type-for-sharepoint-2010-email-validation-field/

COMPATIBILITY_LEVEL Error in SQL

--------------------If you got COMPATIBILITY_LEVEL Error, You have to read following Steps and proceed-------------------------- --COMPATIBILITY_LEVEL { 90 | 100 | 110 } --Is the version of SQL Server with which the database is to be made compatible. The value must be one of the following: --90 = SQL Server 2005 --100 = SQL Server 2008 and SQL Server 2008 R2 --110 = SQL Server 2012 --You have to execute the following query to clear the COMPATIBILITY_LEVEL error ALTER DATABASE DBName   SET COMPATIBILITY_LEVEL = 100; ---------------------------------------------END-------------------------------------------------------------------------------

How to store the sharepoint List or List Item within the recycle bin of the site while deleting it programmatically ?

Whenever we delete a sharepoint list or list item from the User Interface it get stored within the recycle bin of the site. But when we delete it programmatically it get's deleted permanently. So what we can do to store the List or List Item within the recycle bin while deleting it programmatically ? Generally we use the list.Delete() or item.Delete() method to delete the list or item. Instead of using the Delete() method we can use the Recycle() method i.e list.Recycle() or item.Recycle().  This will store the item within the recycle bin.

Merge Query for two database in SQL Server

merge TargetDatabase.dbo.TableName as target using(select * from SourceDataBase.dbo.SourceTable) as source on target.C1= source.C1 when NOT MATCHED BY SOURCE  then DELETE when not matched then  insert(C1)values(source.C1) when MATCHED then update set target.C1=source.C1;

Getting all columns from SQL Table

select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='TableName'

Alerts not being sent in SharePoint 2010

http://www.sharepointed.com/2011/04/21/alerts-not-being-sent/

Error : You do not have an e-mail address. Alert has been created successfully but you will not receive notifications until valid e-mail or mobile address has been provided in your profile

http://vkirshin.blogspot.in/2011/05/specifying-users-email-in-sharepoint.html

BackUp and Restore sites using PowerShell

Site Collection:  Backup-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak Restore-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak -Force Site:  Export-SPWeb http://site –Path C:\site_name.cmp Import-SPWeb http://site –Path C:\site_name.cmp –UpdateVersions -Overwrite

Web Part life cycle in SharePoint 2010

OnInit: This method handles initialization of the control. OnLoad: This event handles the Load event. This is also used for initialize the control but is not intended for loading data or other processing functionality. CreateChildControls: This is the most popular event in web part life cycle. This creates any child controls. So if you are adding any control to display then you have to write in this method. EnsureChildControls: This method ensures that CreateChildControls has executed. EnsureChildControls method must be called to prevent null reference exceptions. SaveViewState: View state of the web part saved. OnPreRender: This method handles or initiates tasks such as data loading that must complete before the control can render. Page.PreRenderComplete: The page fires the PreRenderComplete event after all controls have completed their OnPreRender methods. Render: This method is used to render everything. RenderContents: Renders the contents of the control

Audience and content targeting planning (SharePoint Server 2010)

Click Here to View

Custom Audience Targeting SharePoint 2010

Click Here to view

Export To Excel GridView with Css

 protected override void Render(HtmlTextWriter writer)         {             if (Page != null)             {                 if (bExport)                 {                     Grdshow.Visible = true;                     this.bExport = false;                     Page.Response.Clear();                     Page.Response.Buffer = true;                     Page.Response.ContentType = "application/ms-excel";                     Page.Response.AddHeader("content-disposition", "attachment; filename=Report" + DateTime.Now + ".xls");                     Page.Response.Charset = "UTF-8";                     DateTime ct = DateTime.Now;                     string currentdate = Convert.ToString(ct);                     HttpContext.Current.Response.Write("<b><h1 style='Text-align:left; padding-left:65px; color: #008000; font-weight: bold; font-style: normal; font-size: large'>Amex Report</b></h1>&qu

SPSiteDataQuery ServerTemplate values–“

When creating a list or writing site data query (using SPSiteDataQuery) we all need to indicate the value for “ServerTemplate” attribute, I will leave a list here for my own reference and for anyone who may need these values: 100  Generic list 101  Document library 102  Survey 103  Links list 104  Announcements list 105  Contacts list 106  Events list 107  Tasks list 108  Discussion board 109  Picture library 110  Data sources 111  Site template gallery 112  User Information list 113  Web Part gallery 114  List template gallery 115  XML Form library 116  Master pages gallery 117  No-Code Workflows 118  Custom Workflow Process 119  Wiki Page library 120  Custom grid for a list 130  Data Connection library 140  Workflow History 150  Gantt Tasks list 200  Meeting Series list 201  Meeting Agenda list 202  Meeting Attendees list 204  Meeting Decisions list 207  Meeting Objectives list 210  Meeting text box 211 Meeting Things To

SharePoint 2010 Calculated Column Formula for Two Date Fields

=IF(AND([Date1]="",[Date2]=""),"",IF(AND(NOT([Date1]=""),[Date2]=""),TEXT([Date1],"MM/dd/yyyy"),IF(AND([Date1]="",NOT([Date2]="")),TEXT([Date2],"MM/dd/yyyy"),IF([Date1]=[Date2],TEXT([Date1],"MM/dd/yyyy"),TEXT([Date1],"MM/dd/yyyy") & " to " & TEXT([Date2],"MM/dd/yyyy")))) Scenarios this formula addresses when you have 2 date columns: When both are empty, you would not like to show anything When one is available and another is empty, you would like to show only that available date When both are available and are different, you need to show Date 1 to Date 2 When both are same, only one date must be displayed

Working with SPList Attachements

Here, I am going to share my experience with SPList Attachments. ADDING AN ATTACHMENT TO AN ITEM IN SPLIST :  private void AddNewAttachment(int ItemID)         {             try             {                 SPList myList = SPContext.Current.Web.Lists["Item List"];                 SPListItem myNewItem = myList.GetItemById(ItemID);                 if (fileUpload.PostedFile != null && fileUpload.HasFile)                 {                     Stream fStream = fileUpload.PostedFile.InputStream;                     byte[] contents = new byte[fStream.Length];                     fStream.Read(contents, 0, (int)fStream.Length);                     fStream.Close();                     fStream.Dispose();                     SPAttachmentCollection attachments = myNewItem.Attachments;                     string fileName = Path.GetFileName(fileUpload.PostedFile.FileName);                     attachments.Add(fileName, contents);                  

SharePoint2010 Lists vs PowerShell Scripts

Hi All, Here i have posted the various operations performed on SharePoint 2010 lists through powershell. 1. Create new custom list $SPAssignment = Start-SPAssignment $SPWeb = Get-SPWeb http://chesgh201tw1v:1000 -AssignmentCollection $spAssignment # $SPTemplate = $SPWeb.ListTemplates["Custom List"] # $SPWeb.Lists.Add("Custom List","Description",$SPTemplate) $SPList = $SPWeb.Lists["Custom List"] if ($SPList -ne ''){  #  $SPList.OnQuickLaunch = $True  #  $SPList.Update() } else { } Stop-SPAssignment $SPAssignment 2. Delete a field from the list             $web = Get-SPWeb -identity http://chesgh201tw1v:1605 $list = $web.Lists["TestList"] $column = $list.Fields["RelatedColumn"] $column.Hidden = $false $column.ReadOnlyField = $false $column.Update() $list.Fields.Delete($column) 3. Remove the relationshipbehavior of the lookup field and remove the column from Indexed column             $SPSit

AutoComplete TextBox using JQuery in SharePoint 2010 with SPList values

Image
To achieve this, we have to use SPServices. Get the script from below link: jquery.SPServices-0.6.2.min.js var availableTags = GetListItems(); Add the below function inside the wireEvents() function ///function to get list items using spservice           function GetListItems()           {               var name = new Array();               var index = 0;               $().SPServices               ({                   operation: "GetListItems",                   async: false,                   listName: "Keyword Master",                   CAMLQuery: "<Query><OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy></Query>",                   CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",                   completefunc: function (xData, Status) {                       $(xData.responseXML).find("z\\:row,row&qu

SharePoint 2010 Ribbon Customization Locations

SharePoint 2010 Ribbon Customization Locations Ribbon.BDCAdmin tab Ribbon.BDCAdmin.ApplicationModelManagement group Ribbon.BDCAdmin.ApplicationManagement.Import Ribbon.BDCAdmin.ApplicationManagement.DeleteModel Ribbon.BDCAdmin.ApplicationManagement.ExportModel Ribbon.BDCAdmin.PermissionManagement group Ribbon.BDCAdmin.PermissionManagement.SetPermissions Ribbon.BDCAdmin.PermissionManagement.AssignAdmins Ribbon.BDCAdmin.ApplicationManagement group Ribbon.BDCAdmin.ApplicationManagement.LobSystemSettings Ribbon.BDCAdmin.ApplicationManagement.DeleteLobSystem Ribbon.BDCAdmin.ActionManagement group Ribbon.BDCAdmin.ActionManagement.Add Ribbon.BDCAdmin.ActionManagement.Edit Ribbon.BDCAdmin.ActionManagement.Delete Ribbon.BDCAdmin.ViewManagement group Ribbon.BDCAdmin.ViewManagement.Views Ribbon.DocLibListForm.Edit tab Ribbon.DocLibListForm.Edit.Commit group Ribbon.DocLibListForm.Edit.Commit.Publish Ribbon.DocLibListForm.Edit.Commit.CheckIn Ribbon.DocLibListForm.Edit.

SharePoint 2010 List Template Type Registration IDs

Click Here to view

Use Style Sheet from SharePoint Style Library

<SharePoint:CssRegistration ID="CssRegistration1" Name="/Style Library/yourCSS.css"     runat="server" After="corev4.css" />

Enable Scroll in Chrome When a custom master page is applied

<script type="text/javascript"> jQuery(document).ready(function() {     jQuery("#s4-workspace").height(jQuery(window).height() - jQuery("#s4-ribbonrow").height()); }); </script>