this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Tuesday, May 1, 2012

Do not serialize public property or field in a class


There could be some situation where one have some properties and fields defined in the class. Most of time property are exposed as public and they can be easily accessed by object of class.

During the data transfer serialization of objects happens and at that time we have all the public fields and property contained in the class.

Some situation has special needs to prevent serializing public property or fields. Below code snippent shows how to handle such situation.

[XmlIgnoreAttribute]
        public bool IsActive
        {
            get { return this.mIsActive; }
            set { this.mIsActive = value; }
        }

Have happy coding!!

Wednesday, February 22, 2012

Programmatically create folder in SharePoint Document library with client object model

SharePoint 2010 has very strong client object library, with the help of client object model we can almost interact with all document related functionality from our application and can interact with SharePoint 2010.

Below is some code snippet for creating new folder in the SharePoint Document Library.

public bool CreateSPFolder(string libname, string correspondance)

{

bool bolReturn = false;

ClientContext ctx = this.GetSPClientContext();

Web web = ctx.Web;

List documentLib = ctx.Web.Lists.GetByTitle(libname);

string targetFolderUrl = libname + "/" + correspondance;

Folder folder = web.GetFolderByServerRelativeUrl(targetFolderUrl);

ctx.Load(folder);

bool exists = false;

try

{

ctx.ExecuteQuery();

exists = true;

}

catch (Exception ex)

{

bolReturn = false;

}

if (!exists)

{

ContentTypeCollection listContentTypes = documentLib.ContentTypes;

ctx.Load(listContentTypes, types => types.Include

(type => type.Id, type => type.Name,

type => type.Parent));

var result = ctx.LoadQuery(listContentTypes.Where

(c => c.Name == "Folder"));

ctx.ExecuteQuery();

ContentType folderContentType = result.FirstOrDefault();

ListItemCreationInformation newItemInfo = new ListItemCreationInformation();

newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;

newItemInfo.LeafName = correspondance;

ListItem newListItem = documentLib.AddItem(newItemInfo);

newListItem["ContentTypeId"] = folderContentType.Id.ToString();

newListItem["Title"] = correspondance;

newListItem.Update();

ctx.Load(documentLib);

ctx.ExecuteQuery();

bolReturn = true;

}

return bolReturn;

}

Monday, January 23, 2012

Fix issue HTTP/1.1 200 OK Server: Microsoft-IIS/7.5 Error with a SharePoint 2010 Web Application

Generally, such error comes when we try to browse web-application url. There could be many problems around this problem and depends on it there are different solution for it.

First most common issue around this is that, web application does not contain any site collection at web application root level url, to resolve this you can create site collection from central admin ->Application Management ->Create Site Collection. During creation of site collection, please select your web application where you would like to create.

Second scenario, if you have already site collection created and still this problem occurs. To overcome such problem you have choice to restart IIS, reattach your content database, check services on your pc whether “work station” service is started.

Hope this will help!!

Thursday, January 12, 2012

Prerequisites could not be found for bootstrapping (while upgrading from VS 2005, 2008 to VS 2010)

Latest IDE by Microsoft for .net application is VS 2010. Most of applications are upgraded to newer version of IDE, some are in the process and some are already done. The thing create problem during upgrade is that most of time targeted framework does not change, it just refer older version.

When you try to add prerequisites, you will be surprised that it will not find your older version any more. Many forums said that Microsoft has disabled it and you need to upgrade to higher version of prerequisites.

You can see that in the given below images that shows unavailability.


To resolve this issue you need to copy boots trapper files.

Older version of VS files can be found at

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

You need to copy files from above location to below location and once you copy required folders, you will be able to access those in prerequisites.

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages

Cheers!!

Wednesday, January 11, 2012

Adding Footer to SharePoint 2010 Custom Master Page

When you are going to develop custom layout of your SharePoint site, it could be requirement of having footer in the page. V4 master page does not contain any options to set footer in page.

You need to add footer manually to your custom master page.

If you check your master page you will find below line

Just above that line you can add your custom footer section as below sample markup.

Copyright © 2012 Company. All Rights Reserved.

Style for above div

*Customized foooter */

#s4-customfooter{

clear: both;

padding: 10px;

color: #ffffff;

background-color: #4F5E85;

}

Hope this will help!!

Thursday, January 5, 2012

The Project Item "module1" cannot be deployed through a Feature with Farm Scope

You might have faced such error sometime during your deployment of SharePoint projects. Usually this error comes due to lack of availability of particular item in the scope. You have limited items that can be deployed in the scope of web, site, web application and farm level.

Microsoft has prepared a very nice article to list out it. You can check out here

Monday, December 26, 2011

OOB: Change master page from SharePoint 2010

Most of time we don’t prefer to use conventional user interface provided by SharePoint when we configure it. We want our separate identity when we try to publish our site on base of SharePoint framework.

When you try to find out Changing of master page in your SharePoint, you may not get that options in your Site Settings, first you need to do is to Enable “SharePoint Server Publishing Features”.

To enable above features follow below steps..

Go to Site SettingsàSite Collection Administration à Site Collection Features à Activate SharePoint Server Publishing Features.

Now you may able to see Master pages menu in the Site setting under Look and Feel depends on the version you have installed on your machine.

Alternatively you can directly go to change master page with _layouts/ChangeSiteMasterPage.aspx , just add below url with your site and you will be redirected to change master page for your site.