Friday, December 31, 2010

Register Javascript using SharePoint Feature

You can register JavaScript and CSS without change your SharePoint sites master page.Follow below steps to register JavaScript in master page.

  • Open VS 2010 & create one blank SharePoint 2010 Project.

  • Then Add New Item & select SharePoint 2010’s “Empty Element” and give name “JQueryRegisterElement” as below.

  • Then right click on project and add “SharePoint Mapped Folder” & select “Control Templates” as below.Then add one Usercontrol in this Control Templates folder.

  • Now open Element.xml and add below code for register JavaScript.

Then open UserControl

  • Then Right click on project, Deploy it & open SharePoint Site. You will see below popup.

Happy Coding !!!

Thursday, December 30, 2010

Kill Office Application programmatically

You can kill particular application from multiple applications.
Means create multiple application objects and try to kill it will destroy particular process.
Ex. Create multiple office word document programmatically so every time you open this application one process will create in Task Manager “Word.exe” so after some limited document open your PC will hang.
Due to this I added below code for remove completed process from PC as below code.

Hashtable myHashtable = null;
protected void btn_Click(object sender, EventArgs e)
// get process ids before running the excel codes

//your code for open application like Word,Excel,Access etc....



private void CheckCurrentApplicationProcesses()
Process[] AllProcesses = Process.GetProcessesByName("ApplicationName");
myHashtable = new Hashtable();
int iCount = 0;

foreach (Process ApplicationProcess in AllProcesses)
myHashtable.Add(ApplicationProcess.Id, iCount);
iCount = iCount + 1;

private void KillApplication()
Process[] AllProcesses = Process.GetProcessesByName("ApplicationName");

// check to kill the right process
foreach (Process ApplicationProcess in AllProcesses)
if (myHashtable.ContainsKey(ApplicationProcess.Id) == false)

AllProcesses = null;

Happy Coding !!!

Monday, December 27, 2010

Access denied by Business Data Connectivity

When I tried to fetch SQL Data using BDC using diffrent user then Administrator below error I found. Open Central Administrator Site and then open Application Management Tab's Manage Service Appplications link as below.
Select Business Data Connectivity Service as below
Then after checked your external content type's set object permissions as below.
Add your Users and set permissions as below

Now Open your External List & see all SQL Data.
Happy Coding !!!

Tuesday, December 14, 2010

Chat with SharePoint MVP Experts

Now you can ask your tough sharepoint questions to SharePoint MVP via chat.
Its cover
  • WSS,
  • MOSS
  • SharePoint 2010
Topics include
  • setup and administration,
  • design,
  • development and general questions.


9:00 – 10:00 A.M. Pacific Time
12:00 - 1:00 P.M. Eastern Time
16:00 - 17:00 GMT


Happy Coding !!!

Tuesday, November 2, 2010

Backup Assembly from GAC

Collect Assembly files from Global Assembly Cache
Using below command you can copy Assembly file to your local path.

  1. Open Command Prompt
  2. type this command "copy C:\Windows\assembly\GAC_MSIL\DLLName\\DLLNAME.dll c:\OldDlls_Backup\"

See Example : copy C:\Windows\assembly\GAC_MSIL\MyAssemblyFile\\MyAssemblyFile.dll c:\OldDlls_Backup\

Then see the "c:\OldDlls_Backup\" folder, one file will be copy from GAC.
Happy Coding !!!

Saturday, October 23, 2010

Create Site Template using Sandbox Solution in SharePoint 2010

There are many way to create Site Template in SharePoint.I used below ways in my development experience.
  1. Site Definition. - SharePoint 2010 (Site Definition project type in VS2010) - SharePoint 2007 (SharePoint Solution Generator create Site Definition & also WSPBuider, VSEWss1.3)
  2. Site Provisioning (Programmatically) - You can create easily Site Template using this way because all controls in your hand (in your code). Add SPList, Delete SPList, Provision Web Part etc.
  3. Site Template - For SharePoint 2010, Site Setting > Save as Site Template. Save as .WSP file in Solution Gallery. - For SharePoint 2007, Site Setting > Save as Site Template OR type /_layouts/Savetmpl.aspx in your web url. Save as .STP file in Solution Gallery.

Now I created Custom Site Template in SharePoint 2010 Sandbox.I refer this link.
You can create Web Template Feature in Sandbox Solution & give scope Site for this feature.
Given link will help for me so I hope it will help you.

Happy Coding!!!

Column Level Security in SharePoint

Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007 support a rich security model that allows administrators to control access to sites and content by assigning permissions to users and groups for a specific securable object (such as site, list, library, folder and even an individual document or item).

Currently, SharePoint does not provide out of the box support for securing columns or views.
Here there is good article for securing the columns in SharePoint.

Its working because I used in SPList & Discussion Board.
But there is limitation for lookup field (255 characters) so you can secure item's fields value up to 255 char.

Tuesday, October 19, 2010

Using JQuery Get SharePoint Login User from SharePoint Site

Now Easy to get SharePoint Login User from SharePoint Site

Upload "jquery-1.3.2.min.js" & "jquery.SPServices-0.5.7.min.js"

"jquery.SPServices-0.5.7.min.js" is available here

Add below lines in Javascript Tag & get SharePoint Login User using $().SPServices.SPGetCurrentUser()

$(document).ready(function() {

Happy Coding !!!

Friday, October 1, 2010

Sandbox Solutions Support Elements

Capabilities and Elements in Sandboxed Solutions
Sandboxed solutions support the following capabilities and elements:

  • List Definitions

  • List Instances

  • Onet.xml

  • WebTemplate feature elements (instead of Webtemp.xml)

  • Content Types/Fields

  • Navigation

  • Module/files

  • Feature callouts

  • Web Parts

  • Support for all Web Parts that derive from System.Web.UI.WebControls.WebParts.WebPart

  • Event receivers

  • SPItemEventReceiver

  • SPListEventReceiver

  • SPWebEventReceiver

  • Custom actions

  • Declarative workflows

Sandboxed solutions do not support the following capabilities and elements:

  • Visual Web Parts

  • Application Pages

  • Custom Action Group

  • HideCustomAction element

  • Content Type Binding

  • Web Application-scoped features

  • Farm-scoped features

  • Workflows with code

Monday, July 12, 2010

VB.Net Error on SharePoint feature deployment

VB.Net Error on SharePoint feature deployment

Before few days i had converting my C# code into and I faced one problem in Assembly reference part.

Failed to create feature receiver object from assembly "SampleWebFeature,version=,culture=nutral, Publickey Token=xxxxxxxxxxxx".

My same C# code working for this feature but code fire this error.

Almost I got the point, the problem occured in assembly reference and Reflector help me to identify the problem.

C#'s dll class refer : SampleWebFeature,version=,culture=nutral, Publickey Token=xxxxxxxxxxxx
VB.Net's dll class refer : SampleWebFeature.SampleWebFeature,version=,culture=nutral, Publickey Token=xxxxxxxxxxxx

Then opened Project's Property window and removed "SampleWebFeature" and then build DLL and checked in Reflector.

Both refer same then move dll to GAC and tried to activate feature and it worked.

Custom XSLT for the Search Core Results Web Part

Custom XSLT for the Search Core Results Web Part

Use below lines for getting default columns in xslt core result webpart.

Open Core Result web part in edit mode and change Out-of the Box XSLT with below lines.

Save this web part.

Now you can see default records in XML format.

Happy SharePointing...

Wednesday, July 7, 2010

Remove search scopes from Search scopes Dropdown list using JQuery.

Easy to remove Search scopes from Out Of the Box Search Scope Drop down list using JQuery.
Use below JQuery for remove Scopes from Dropdown list.


$("select[id$='SBScopesDDL'] option:contains('Scope2')").remove();
$("select[id$='SBScopesDDL'] option:contains('This Site:')").remove();

Monday, June 28, 2010

Programmatically get SSP URL of Farm

Programmatically get SSP URL of Farm

If you are playing with farm than easily get Farm's SSP URL as per below code lines or Use below function.

public static string GetFarmSSPURL()
string url = string.Empty;
ServerContext sc = ServerContext.Default;
object ssp = sc.GetType().GetProperty("SharedResourceProvider",
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(sc, null);
Guid sspGuid = (Guid)ssp.GetType().GetProperty("AdministrationSiteId").GetValue(ssp, null);
using (SPSite sspSite = new SPSite(sspGuid))
url = sspSite.WebApplication.GetResponseUri(SPUrlZone.Default).AbsoluteUri + "ssp/admin";
return url;

Monday, June 21, 2010

SharePoint ServerTemplate 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 Bring list
212 Meeting Workspace Pages list
300 Portal Sites list
301 Blog Posts list
302 Blog Comments list
303 Blog Categories list
850 Page Library
1100 Issue tracking
1200 Administrator tasks list
2002 Personal document library
2003 Private document library

Monday, May 3, 2010

Problem with MOSSRadEditor base class in RadEditor for MOSS 4.5.6

Problem with MOSSRadEditor base class in RadEditor for MOSS 4.5.6

I tried to add MOSSRadEditor in sample WebPart so I downloaded ASP.NET RadEditor for MOSS Lite Edition from below free Telerik Control link.
As per MOSSRadEditor help file I got 3 dlls for WSP and add to my WebPart project but I can’t find MOSSRadEditor Constructor as below
MOSSRadEditor objMOSSRadEditor = new MOSSRadEditor(); //not define MOSSRadEditor Constructor

The type 'Telerik.SharePoint.MOSSRadEditor' has no constructors defined

Resolution: I googled this problem and found the problem reason (WSP contains light DLLs). So I got one Telerik Support link ( ).This link contains one Reference code which use FULL DLLs so I download this DLLs and use it in my WebPart code.

Result: Its working fine.

Advantage: MOSSRadEditor Support all Browsers like IE, Firefox, Safari etc (I tried for this 3 browser).

Happy Coding !!!

Thursday, April 22, 2010

Filter in List View using Query String

Filter in List View using Query String

It’s very easy to filter in built list view web part OR SPList in UI.
Below query string is filter list.
?FilterField1=[Internal Field Name]&FilterValue1=[Value of Filter Field]
For more understanding let’s take one example.
Here I created one sample List which contains Title, Date, City and Country Columns as per below.

Now I want to filter on Country Column so query string looks like
Happy Coding !!!

Monday, April 12, 2010

SharePoint Site Cannot connect to configuration database

Error Message : Cannot connect to configuration database

Cause : When you try to open SharePoint site below error fire on your screen that means your Site can't connect SQL Server Database.

Resolution : Check your SQL instance Service from MS Services. If stopped SQL instance Service then Start it.

Example: Start > type this in RUN "services.msc " > as per below SQL Instance Start it from property.

Happy Coding !!!

Saturday, March 27, 2010

SharePoint 2010 Installation on Windows 7

Now very easy to install SharePoint 2010 beta on Windows 7 OS.
Below link is very usefull to install SharePoint 2010 beta on your Windows 7.

Tuesday, March 16, 2010

Windows SharePoint Services Search Service

When you will try to start Windows SharePoint Search Service but not start it & fire below error.
"Could not Start Windows SharePoint Services Search Service on Local Computer."

Modify the "Log On" Identity of the service as per below Image. In my machine, it was setup to log on as "Local Service". After changed this to "Local System", the service started without any errors.
Happy Programming with SharePoint !!!

Wednesday, March 10, 2010

The request failed with HTTP status 401: Unauthorized.

The request failed with HTTP status 401: Unauthorized.

This issue occurs if you install Microsoft Windows XP Service Pack 2 (SP2) or Microsoft Windows Server 2003 Service Pack 1 (SP1). Windows XP SP2 and Windows Server 2003 SP1 include a loopback check security feature that is designed to help prevent reflection attacks on your computer.
Below 2 methods are useful to solve above issue.
1. HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Control > Lsa
Right click and New > DWORD Value
“DisableLoopbackCheck” then right click on this and modify value data to “1”

2. HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Control > Lsa > MSV1_0
Right click and New > Multi String Value
“BackConnectionHostNames” and add multiple host name value.

For more details see