Posts

Showing posts from June, 2015

How to overload a web method in web service - ASP.Net

We can define Method Overloading as , Same Methods name with different type of parameter or different set of parameters.

Web method overloading is not straight forward in use.

C# Code to get user details from FaceBook

In this blog i am going to explain about how some one can get user details from Facebook and later use data for user registration, user login and for some other purpose.

First you need to create a Facebook APP, You can check here how to create facebook app.

How to create a blank SharePoint Page? SharePoint Branding

I was working on a project where all my SharePoint inherits from a custom master page with predefined Page Layout.

I got a requirement where i need to create few pages with different layouts.

There are various ways to do this. One is to create a new Page Layout by coding and select your layout while adding new page to Page library, another way is to create a new master page (i.e. create a blank master page).

I followed second option. I created a copy of existing master and modified it accordingly.


I added a page with existing Page Layout.I opened that page in SharePoint Designer 2010 and changed the master page name from top of the section.

<%@ Page language="C#" MasterPageFile="../_catalogs/masterpage/blank.master" ......


I checked in file and published.but it was showing my custom master page layout.This is because your page is attached with an existing Page Layout.To detach page layout, open Page Library, Right Click on Page and Select "Detach from Page La…

Introduction to Linq to SharePoint

Introduction to Linq to SharePoint
LINQ is a way to access external data sources.SharePoint Foundation 2010 comes with its own LINQ to SharePoint provider.
The namespace which contains the provider is Microsoft.SharePoint.Linq.dll.

What is Parent Content Type in SharePoint 2010?

What is Parent Content Type in SharePoint 2010?As you know content type in SharePoint gives re-usability features.
Parent Content Type is a hierarchical relationship between two content types. Parent Content Type defines the properties for a child content type which inherits all properties of parent content type.

How to create workflow in SharePoint Designer

Workflow is a process to break down a job/work into several segments to make the business easy and simple. Or, Workflows in SharePoint Designer are there to help you to create automated business processes. A sample workflow is a simple approval workflow. When an item is saved to a SharePoint list with an approval workflow association, the item is routed to an "approver", where he can then either approve or reject the new item.

For example, suppose some people in your organization have the task to write, review, and approve contracts. They save them in a document library in their team website. To help them automate administration, you can use SharePoint Designer to create a route that sends an e - mail message to the reviewer when a new agreement has been added to the site. At the same time, a task can be created in the reviewer ’ s task list. When the person reviewing this agreement specifi es that the task is complete (approved or not), a variety of actions can be set thro…

Facebook login on website with Java Script Code

Facebook is a popular social media. Most of the website provide login with facebook feature, why because each and every user over internet have facebook account. So login with facebook feature avoid filling a new signup form on a new website.


How to Crop and Upload image using JQuery

In this blog, I will explain how to crop an image and then upload that image using JQuery. Here you will come to know about preview an image, and then crop that image and finally upload it using JQuery and C# code.  This implementation has been done using JQuery, so no postback only smooth user experience.

Three State Workflow in SharePoint 2010

Three State Workflow in SharePoint 2010
1. Create a list with below structure, as shown in the screen.

2. Make sure, status column should be of choice and add 3 values as shown below.

3.  Add a workflow to the list, with below steps.

4. Select "Three-state" from workflow template. Give a name to workflow. Make sure "start this workflow when a new item is created" is checked.
5. Now you can see the workflow states are the options that were entered in "status" column of the list.

6. Enter email id and subject line to whom you want to send email when workflow will initiate.
7. Enter email id and subject line to whom you want to send email when workflow changes to its middle state.

8. Now come to your list and create items. Hope workflow should work.

Calling ASP.Net WebMethod using jQuery AJAX

Before reading this blog, you can read some of my popular blogs - ASP.Net Tutorial, WCF Tutorial, .Net Core Tutorial, JQuery Tutorial In this blog, we will first know about Web Method.

How to consume RESTful APi from server side code - C#

I was working on a project where I got a Web API URL with parameters, I was asked to consume this API and get the response from there.


CAML Query Tutorial for SharePoint 2013 and 2010 - A Complete tutorial guide

CAML Query is one of the most important topics in SharePoint. CAML Query is the way for querying items from SharePoint objects like List and Library. This blog is helpful in SharePoint 2010 development as well as in SharePoint 2013 development.

All about SharePoint 2010 Content Type Hub - SharePoint 2010 Tutorial

What is Content Type Hub in SharePoint 2010?Content type hub is a new feature which comes with Managed Meta Data Service in SharePoint 2010. I have worked with SharePoint 2007 and I know that there is a problem for creating an enterprise library and sharing them across the site collections. 

SharePoint 2010 Enterprise Content Management

What is Enterprise Content Management? Enterprise Content Management can refer to all kinds of sources, including electronic documents, scanned images, e-mail, and web pages.

Working with BCS and External List in SharePoint 2010

In this blog, I will explain about BCS (Business Connectivity Services) and how we can implement BCS in SharePoint 2010.

Bind a InfoPath dropdown with SharePoint List

This article explains about binding infopath dropdown with SharePoint List data.
Posted on :27th Jul 2014 Suppose you have a requirement, you need to bind SharePoint list data to dropdown in Infopath. Simply you want to use SharePoint list as your data source for Infopath dropdown list. Follow below steps with given screen shot.

Step 1: Open Microsoft InfoPath 2010, Click on SharePoint List from Available Form Template, as shown in Below screen shot.

Step 2: Give url of your SharePoint web application where your list is available.

Step 3: Select "Customize an existing SharePoint list" option, and choose your list, click next.

Step 4: Click Finish as per below screen shot.

Step 5: Drag a dropdown list on new form as shown in below image.

Step 6: Select "Look up choices from a SharePoint list" option. Select your list and field which you are going to bind.

Step 7: Run your form by pressing F5 and you will see the result like this.

Using a web service in SharePoint InfoPath form

Web service is a way to communicate between 2 machines via HTTP, those 2 machines can be on a different platform. To know more about Web Service read my previous blog - All About Web Service, SOAP and RESTful
In this blog, we will see how to Consume Web Service in InfoPath Form.

Lookup column is blank after moving the list as STP file from one environment to another.

Do you know the importance of lookup column in sharepoint list?Its the kind of field in a list which pulls data from another field of a List.Suppose if you have two list called ListA and ListB in your sharepoint web application.You created a field in ListB of type Lookup and lookup data is coming from ListA.

Till now its working fine for you.

Now, you moved these 2 lists (by save as template) from Development environment to Testing or Production.
You found that your data in lookup field of ListB is empty.

The reason here is once you moved the list to new environment the list id will be changed, so in this case ListA id will
be changed and lookup field of ListB will not able to identify the list.

So how to resolve this?

Follow below steps to overcome this problem:

Click on ListA (from Left navigation pane), then go to list setting once you click list setting of ListA,
in address field of browser copy the List id.(see below url)

http://mycomputername:2010/_layouts/listedit.aspx?List=%7…

How to create a 404 or Custom Error Page in SharePoint 2010

404 Error page is a standard to display a page with your own message if user mistype a page name. To configure custom error page eg HTTP 404 Page not found error in SharePoint 2010. It is a good practice to create custom error page. To do so just follow below steps:

1. Go to _layouts/1033 folder and find SPS404.html.
2. Copy this SPS404.html and paste it at same location.
3. Rename this new file for eg : SPSCustom404.html.
4. Edit SPSCustom404.html file in any text editor.
5.Search for  STSNavigate("/Pages/Pagenotfound.aspx?oldUrl=" + requestedUrl);
6. /Pages/Pagenotfound.aspx is the page location which you want to display in case of HTTP 404 error occurs.
7. Once you done with editing, save and close this file.
8. Open SharePoint 2010 Powershell.
9. Run below command
$WebApp = Get-SPWebApplication "siteurl"
$WebApp.FileNotFoundPage = "SPSCustom404.html"
$WebApp.Update()

Now you are done, just type a wrong page name with your webapp url and see the result.

Error-The Method GetItems of the type List with id is blocked by the administrator on the server

Recently i was working with SharePoint Client object model, suddenly I face an issue while accessing fetching SharePoint list data. Error was-The Method “GetItems” of the type “List” with id “{Lists’s Guid}” is blocked by the administrator on the server

After searching over internet i found the solution and it worked for me:

To solve this issue you need to run below powershell command.

$web = Get-SPWebApplication -Identity siteurl
$web.ClientCallableSettings.AnonymousRestrictedTypes.Remove( [Microsoft.SharePoint.SPList],"GetItems")
$web.Update()

After running this command please refresh your page and hopefully you will see the result.

How to link 2 SQL DB servers

If someone wants to get data from 2 tables from 2 different SQL DB server. Then execute below stored procedures before running your query.

Step1: exec sp_addlinkedserver    @server=db-server-name

Step2: EXEC sp_addlinkedsrvlogin db-server-name, false, NULL, id, password

Once you executed above SPs successfully, you can check linked server list by executing below SP.


exec sp_linkedservers

How to add file in root of a sharepoint web application?

SharePoint folder structures are different, generally pages will be available in Page library. What if a user wants to add a file in root of SharePoint web application.

Generally sitemap and robots files are added to root.
Below is the powershell command which can add file to root location.

$fileBytes = [system.io.file]::ReadAllBytes("D:\MyFolder\sitemap.xml");
$site = Get-SPSite "http://server:80";
$site.RootWeb.Files.Add("sitemap.xml", $fileBytes, $true);

SharePoint central administration page is blank after sharepoint installation

I have installed sharepoint 2010 successfully, even i have completed sharepoint configuration wizard with no error, but still i got blank central administration page.

What is SPDisco.aspx file in Sharepoint 2010?

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"

How to get the internal name of a column in a sharepoint list?

I was working on a SharePoint project, suddenly i got this error saying "The property or field not initialized".

I searched over net and found that the internal name of a field or column in SharePoint list might be different.

Then I searched how to know the internal name of a field in sharepoint list and found the solution.

This is a powershell command which list out all the field with their internal name.

Here is the command for powershell:

$web = Get-SPWeb http://sharepointcafe:80
$list = $web.Lists["MyListName"]
$list.fields | select Title, InternalName, Hidden, CanBeDeleted | sort title | ft -AutoSize

You might also get the internal names by client object model code.

What is collection in C#

Collection classes are used to store data of specific types. All types of collection support IEnumerable interface.

Below are collection classes used in C#.net, all classes come under System.Collection namespace.

Difference between constant, readonly and static in C#

Constant and ReadOnly keyword are used to make a field constant which value cannot be modified. Static keyword is used to make members static that can be shared by all the class.

Constant
Constant fields or local variables must be assigned a value at the time of declaration and after that they cannot be modified. By default constant are static, hence you cannot define a constant type as static.

void Calc(int k)
{
 const int i = 10, j = 50;
 const int x = i + j; //no error
 const int a = x + k; //gives error
}

ReadOnly
A readonly field can be initialized either at the time of declaration or with in the constructor of same class. Therefore, readonly fields can be used for run-time constants.

Static
The static keyword is used to specify a static member, which means static members are common to all the objects and they do not tied to a specific object. This keyword can be used with classes, fields, methods, properties, operators, events, and constructors, but it cannot be used with indexers, d…

Exception handling in C#

Exception Handling in C#. Most .NET languages support exception handling. Essentially, when an error occurs in the application, the .NET Framework throws an exception that represents the problem.

You can catch this object using an exception handler. If you fail to catch exception, code will be aborted, and the user will see an error message on page.
Visual Studio provides a useful tool to browse through the exceptions in the .NET class library. Simply select Debug ? Exceptions from the menu

Exception Handling with Try  and Catch

protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            decimal a, b, result;
            a = Decimal.Parse(txtNum1.Text); 
            b = Decimal.Parse(txtNum2.Text); 
            result = a / b; 
        }
        catch (Exception err)
        {
            lblResult.Text = "<b>Message:</b> " + err.Message + "<br /><br />"; 
            lblResult.Text += "<b>Source:</b>…

When should i use Response.Redirect(url,false) in C# code

What is the use of True and False in Response.Redirect? First parameter in Response.Redirect define redirection to next page but true/false tells whether to stop or continue processing the next line.

True or False parameter in Response.Redirect tells whether to continue the code execution or terminate the next line execution on that page.

Look at below piece of code.
In below code, after Response.Redirect for loop execution will continue.

Response.Redirect("Page.aspx",false);
        for (int i = 0; i < 10; i++)
        {
            i++;
        }



In below code, after Response.Redirect for loop execution will be terminated.

Response.Redirect("Page.aspx",true);
        for (int i = 0; i < 10; i++)
        {
            i++;
        }

How to enable publishing feature in a team site in SharePoint 2010

How to enable publishing feature in a team site in SharePoint 2010

On a team site also publishing feature can be enabled.But once you enable the Publishing feature on a collaborative site, such as a team site or a blank site, you can no longer save that site as a template. This is something you should be aware of before making the choice to enable specific features or functionality on existing sites.


From the SharePoint Central Administration site, create a new site collection from the Application Management section using the Team Site template called “SPCafeTeam Site.”From the main page of your new team site, select Site Settings from the Site Actions menu.Select Site Collection Features from the Site Collection Administration links.Click the Activate button next to the SharePoint Server Publishing Infrastructure feature.Return to the Site Settings page of your site.Select Site Features from Site Administration links.Click the Activate button next to the SharePoint Server Publishing …

Type is not registered as safe- Error is coming when deploying the web part to SharePoint site.

Type is not registered as safe- Error is coming when deploying the web part to SharePoint site.

Type is not registered as safe Error is coming when deploying the web part to SharePoint site.
As you all know while deploying web part from visual studio to SharePoint site, you need to care about few things.
There are numerous types of error may come when you will perform the deployment of web part to SharePoint.
One of the errors is “Type is not registered as safe”.
So why this error is coming and how to resolve it.
In this forum I will write about this error, as I have already faced this problem when I was deploying my web part into SharePoint site.
So first you should know how to create a webpart and how to deploy it.
To know this you can go here.


Before deploying the web part, be sure you add the strong key name within <safecontrol>…</safecontrol> tag in web.config file.
Then open your web part project in visual studio.
Select web part folder
Press F4(or right click and o…

Difference between interface and abstract class

Difference between abstract class and interface is one of the most asked question in interview.
Lets have a look on difference between interface and abstract class. 

Abstract Class vs Interface 


Abstract classed can have implementation for some of its members, but interface can not have implementation of any members. An interface can not contain fields but an abstract class can contain fields. Interface members are by default public and no explicit access modifier require, but abstract class members can have access modifiers. An interface can be inherited from another interface only and not from an abstract class, but abstract class can inherit from another abstract class or from interface.Interface can not contain constructors.