Showing posts from 2011

What are Application Pages in SharePoint?

Application pages are very important in context of SharePoint. Application pages are stored in layout folder. Unlike site pages (for example, default.aspx), a custom application page is deployed once per Web server and cannot be customized on a site-by-site basis. Application pages are based in the virtual _layouts directory. In addition, they are compiled into a single assembly DLL. A good example of an Application Page is the default Site Settings page: every site has one, and it's not customizable on a per site basis (although the contents can be different for sites). With application pages, you can also add inline code. With site pages, you cannot add inline code. Typically, you link custom application pages to application.master, the master page file that is used by the default application pages in Windows SharePoint Services. You should also write application pages to inherit from a base class defined inside the Microsoft.SharePoint assembly named LayoutsPageBase.

What is Nullable types in C#

What is nullable type in C# code. Please explain with example

Nullable types was introduced in C# 2.0.
Nullable types are instances of the System.Nullable<T> struct. A nullable type can represent the range of values for its underlying data type, also an additional null value.

For example, a Nullable<Int32>, pronounced "Nullable of Int32," can be assigned any value from -2147483648 to 2147483647, or it can be assigned the null value.

A Nullable<bool> can be assigned the values true, false or null.

Try below code :
class NullableTypeExample
static void Main()
        int? number = null;
        if (number.HasValue == true)
            System.Console.WriteLine("Value= " + number.Value);
            System.Console.WriteLine("number = Null");

        // y is set to zero
        int y = number.GetValueOrDefault();
//number.Value throws an InvalidOperationException if num.HasValue is false

Dictionary in C sharp. Please explain with code

What is dictionary in C#.Please explain. The Dictionary type in the C# language provides fast lookups with keys to get values.
It allows you to use keys and values of any type, including ints and strings.
using System;
using System.Collections.Generic;

class Program
    static void Main()
        Dictionary <string, int> dictionary = new Dictionary<string, int>();
dictionary.Add("cat", 2);
dictionary.Add("dog", 1);
dictionary.Add("llama", 0);
dictionary.Add("iguana", -1);
dictionary.Add("iguana", -1);

What is information management policies in SharePoint2010

What is information policies in SharePoint.

A policy, as defined by MOSS, is a set of rules or guidelines that govern the creation, use, and disposition of a particular item, site, collection, list, library, page, and so on.
Such as information management policy defines who can access documents of a certain content type, what users can do with these documents, and, where applicable, how long the document is retained.
Information Management Policies on a SharePoint Site
A SharePoint information management policy can be created on a site using three different
Create an information management policy on the site collection.
Create an information management policy on a site content type.
Create an information management policy on a list or library.
Site Collection Policies
The best way to ensure an information management policy is applied to all the
documents of a certain type is to create the policy at the site collection level and then apply
it to the content types to be man…

Executing Server side code in sharePoint or use of PageParserPath

Executing Server side code in sharePoint or use of PageParserPath

Application pages in sharepoint behave like pages where they may contain inline server code.  Wheras site pages are rendered as safe mode parser so there is no problem with these type of pages.
The problem comes with application pages i.e. pages. SharePoint will not allow any pages to be render which contains in line server code.  If you can say here sharepoint shows its limitation towards development. But there is a way to overcome this problem. If you want to render pages with inline server code then you can use <PageParserPath>…</ PageParserPath>.
So, how to use PageParserPath to render pages with inline server code.
Go to the web.config file of SharePoint and search for <SharePoint> tag, within it you can use page parser path like this.
<PageParserPath VirtualPath="/myFiles/*" CompilationMode="Always"
AllowServerSideScript="true" IncludeSubFolders=&qu…

Concept of boxing and Unboxing in C sharp

Boxing and Unboxing concept in C# language. Explaining with code.

Boxing: Boxing refers to the process of moving from a value type to reference type.
Un-Boxing: Un-Boxing refers to the process of moving from a reference type to value type.
Public void BoxingUnbox()
            int i = 10;
            object obj = i;//boxing
            int j = (Int32)(obj);//un-boxing
 But in context of performance using boxing and unboxing is not a good practice.
Now below code illustrate the boxing and simple assignment of value by showing the timer. The code is tested on 10000 values. See below code:
class Program
        static void Main(string[] args)
            Console.WriteLine("Enter choice box/nobox");
            string readkey = Console.ReadLine();
            if (readkey == "box")
                Stopwatch obj = new Stopwatch();
                for (int start = 0; start <= 10000; start++)

Bulk copy data from excel sheet to sql table

How to process bulk copy data from excel sheet to sql table. Here is code to copy data from excel to sql.

      C# Code:
string excelFile = @"C:\Book1.xls";
        string ssqlTable = "[MyTableName]";
        string exceldataQuery = "select [id],[email],[status] from [Sheet1$]";
            string sexcelconnectionstring = @"provider=microsoft.jet.oledb.4.0;data source=" + excelFile +
            ";extended properties=" + "\"excel 8.0;hdr=yes;\"";
            string ssqlconnectionstring = "Data Source=dbserver;Initial Catalog=Practice;User ID=sa;Password=@password;connection timeout=54000;Max Pool Size=300;Asynchronous Processing=true;";
            OleDbConnection oledbconn = new OleDbConnection(sexcelconnectionstring);
            OleDbCommand oledbcmd = new OleDbCommand(exceldataQuery, oledbconn);
            OleDbDataReader dr = oledbcmd.ExecuteReader();

Lets Learn SharePoint

What is SharePoint? SharePoint is a platform for collaboration, document sharing, meeting, record management, content management, business intelligence kit. SharePoint marketing tagline is “Business Collaboration Platform for Enterprise and Web”.
Let’s understand SharePoint by an example:
Suppose a project manager was assigned a new project in his organization. Let’s name this project manager as Mr. A
So Mr. A will send emails to HR and other projects Managers to know following things:
How many resources are free? How many resources are expert in designing, How many are in .Net technology etc.
After that Mr. A will gather his team and will held some meeting, then few email exchange, document sharing via email, telephonic conversations and many more.
Few weeks later Mr. A will have to expand time to search for a particular document, he needs to scribble his email folders, he needs to ask his team mates for a particular things.
Are these work going to give any result? Might be or might no…

Architecture of SharePoint 2010 Development Platform

Architecture of SharePoint Development Platform

SharePoint uses List, Library, Content Type for Data Management in a SharePoint Web Application.
How SharePoint Code Deployed to SharePoint Web Application? SharePoint websites are similar to ASP.Net websites as they are hosted in IIS. However There are differences in the process of code deployment. SharePoint code is deployed to SharePoint web application in the form of WSP (Windows Solution Package).
Visual Studio has the feature to make a wsp package. That WSP file can be deployed either by central admin UI or PowerShell Command. Assembly Deployment  (DLL) There are 2 ways that a SharePoint Web Application can access assembly files. GAC/Full Trust : Assemblies are deployed into Global Assembly Cache (GAC). They are accessible from any SharePoint Web Application on the farm. Bin: Assemblies are deployed to bin folder of specific SharePoint web application.

SharePoint topics for Beginners

SharePoint Topics for Freshers:
SharePoint ArchitectureSharePoint Environment StructureCentral AdministrationTop Level Site, Site Collection, SiteSharePoint Object (List, Library, Content Type)SharePoint Coding Model (Client and Server Object Model) InfoPath FormFeatures and Event ReceiverTimer JobsOOB WorkflowSharePoint DesignerMaster Page Customization