Sunday, November 22, 2009

SharePoint 2010 Beta 2 and Silverlight 4 Beta available

Microsoft announced the availability for SharePoint 2010 Beta 2

http://blogs.msdn.com/sharepoint/archive/2009/11/18/sharepoint-2010-public-beta-is-now-available-for-download.aspx

At the PDC in n Los Angeles, Scott Guthrie announced the availability of Silverlight 4 beta:

http://team.silverlight.net/announcement/silverlight-4-beta-is-now-available/
http://www.silverlight.net/getstarted/silverlight-4-beta/

Saturday, November 7, 2009

What are Sharepoint Querystring Parameters?

Here are some Query String parameters that I think every SharePoint Developer\Implementer must know about it
 
To open the Web Part Maintenance Page

"?Contents=1"


To Open the Page in Web Part Design Mode

"?ToolPaneView=2"


To Open the Search Web Part Zone

"?ToolPaneView=3"


To open the Design Bar - Useful for pages in the Pages Library

"?DisplayMode=Design"


To turn on Web Part Zone Editing

"?ControlMode=Edit"


To Show the Shared version of a page

"?PageView=Shared"


To Show the Personal version of a page

"?PageView=Personal"

Sunday, October 11, 2009

How to Insert Item in Sharepoint List using WebService with Javascript

Without using Sharepoint API we can achieve by OOB. In following code I have inserting items in MyList and ID and Title.

You can call the from a button with the following code

<input type="button" value="Save List Item" onclick="javascript:SaveListItem();">

function SaveListItem()
{
var soapRequest = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">' +
' <soap12:Body>'+
' <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'+
' <listName>TestList</listName>'+
' <updates>'+
'<Batch OnError="Continue">'+
' <Method ID="1" Cmd="New">'+
' <Field Name="ID">New</Field>'+
' <Field Name="Title">TestData</Field>'+
' </Method>'+
'</Batch>'+
' </updates>'+
' </UpdateListItems>'+
' </soap12:Body>'+
'</soap12:Envelope>';
xmlHttp=new XMLHttpRequest();
xmlHttp.open('post', 'http://ServerName/SiteCollection/_vti_bin/Lists.asmx', true);
xmlHttp.setRequestHeader('Content-Type','application/soap+xml; charset=utf-8');
xmlHttp.send(soapRequest);
}

Saturday, October 3, 2009

How to Delete attachment from an Item in Sharepoint List

public static void DeleteAttachements(int id)

{
using (SPSite site = new SPSite("http://portal"))
{
using (SPWeb web = site.OpenWeb())
{
SPListItem listItem = web.Lists["mylist"].GetItemById(id);
List<string> fileNames = new List<string>();
foreach (string fileName in listItem.Attachments)
{
fileNames.Add(fileName);
}
foreach(string fileName in fileNames)
{
listItem.Attachments.Delete(fileName);
}
listItem.update();
}
}
}

Thursday, September 24, 2009

How to Update User Profile using C#

using (SPSite site = new SPSite(“http://portal”))

{
Microsoft.Office.Server.ServerContext Context = ServerContext.GetContext(site);
Microsoft.Office.Server.UserProfiles.UserProfileManager Mngr = new UserProfileManager(Context);
Microsoft.Office.Server.UserProfiles.UserProfile Profile = Mngr.GetUserProfile(“litwareinc\ashishk”);
System.Console.Write(Profile[“Title”].Value.ToString());
Profile[“Title”].Value = “New Title”;
Profile.Commit();
}


Bingo, here ashishk Title is updated with "New Title"