Tuesday, October 28, 2014

Remove special characters from SPUser

When you are retrieving the SharePoint Group / User detail on custom application page or webpart you might seen those details were comes with special character and number format.
The number denotes the SiteUser Id or Group Id in the site collection.
To removing the special character and number in the scrambled text use this simple Regular expression format
This stripes the number and special character from the string.
string Name = "1234;#Murugesa Pandian";
Regex.Replace(Name, @"[0-9#;]", string.Empty);

HtmlTable DataTable loop

This simple code will help you to understand on how to loop through the DataTable in C# and showing the result in HtmlTable,HtmlTableRow and HtmlTableCell in C#

      var list = SPContext.Current.Web.Lists["Departments"];
            SPQuery query = new SPQuery();
            query.Query = "1";
            DataTable dt = list.GetItems(query).GetDataTable();

            HtmlTable table = new HtmlTable();
            HtmlTableRow hrow = null;
            HtmlTableCell cell = null;
            int index = 0;
            hrow = new HtmlTableRow();
            foreach (DataColumn col in dt.Columns)
                cell = new HtmlTableCell();
                cell.InnerHtml = col.ColumnName;

            foreach (DataRow drows in dt.Rows)
                hrow = new HtmlTableRow();
                for (int hcol = 0; hcol < dt.Columns.Count; hcol++)
                    cell = new HtmlTableCell();
                    cell.InnerHtml = drows[hcol].ToString();

            //--->Write logict to see

Monday, October 20, 2014

LookUp Column Caml Query

If you want to query the Lookup column in the SharePoint, you need to specify the value type "Lookup" in CAML query.

Example Code

Friday, October 17, 2014

SharePoint 2013 Client Object Model - basic understanding

SharePoint Client Object Models

Javascript (JSOM )
You have to use this model if you host your client application within SharePoint server.
You have to include the SP.js file which is located in layout folder in 14 hive.
You can leverage the the power of JSOM conjunction with JQuery for dynamic content rendering on your client application.

Managed Object Model (CSOM) : Its .NET libraries and can be used in and out of SharePoint server, In this model you need to pass your credentials to talk with SharePoint.
You need to add the Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime assemblies. You have locate these dlls in ISAPI folder.

Silverlight Object Model (SOM): Can be used any of the Silverlight application.
You need to add the Microsoft.SharePoint.Client.Silverlight and .Silverlight.Runtime assemblies. You have locate these dlls in layouts\ClientBin folder.
I am sure,It could be abbreviated to SOM  :)

All of the client side object has some advantage and limitation over Server side object model.
These models are just a layer to talk with SharePoint through built-in WCF service named "Client.svc".

The request from this models were sent to SharePoint through XML and the response from SharePoint will be JSON format and then it can be parsed.

SharePoint Client Object Model also supports the Anonymous and FBA (Form based Authentication).

You can also write RunWithElevated privilege equivalent in Client object model by passing the Network credential to ClientContext class.

It supports synchronous and asynchronous method calling.

In SharePoint 2013, Microsoft updates the Client Object Model to be worked on Managed Meta data,User Profile Service and Search Service application through REST API and CSOM.

Thursday, October 16, 2014

SharePoint 2010 Installation in Windows 8

Easy ways to install the SharePoint 2010 on Windows 8

Its highly recommended not to use the SharePoint on Client OS,but often developer or learner wanted to play on their personal computer.

Here,I gone through many helpful sites for installing the SharePoint 2010 on Windows 8, and its not helps as much as so simple.

Be sure you are using the Windows 8 64 bit.

  • Install "Filter Pack" [You can find it on "Prerequisites" folder in SP installation folder].

  • Activate the Windows Features , Windows Identity Framework 3.5 and IIS.

  • Install the Visual Studio 2010 (Custom) and choose SQL Express.

  • After this restart your PC and run the SharePoint setup.exe file.

Saturday, October 11, 2014

C # Oops PDF

Last week, I was in Chennai I happened to meet one engineer student and he was religiously preparing for his interview.

He had lot of  e-books related to almost all technologies and I liked his selection "Oops concept in C#".

I am in still learning and wanted to update my skills in the basics,So I asked him to transfer this PDF file.

All credit goes to that guy and whoever compiled all this questions and answer pattern.

Here I am sharing it with you.

C# - Oops beginner document