Posts

SharePoint Edit Page and Personalize page using Javascript

I had to dig deep to find out what are the javascript functions called when we click the Edit Page button the SharePoint ribbon. I had to hide the ribbon for one of my client's requirements and i had to provide links for Edit Page, Personalize page and Save page. I have used three hyperlinks for each of these functionalities. This is how we can do it in SharePoint. <a href="javascript:ChangeLayoutMode(false);">Edit</a> <a href="javascript:ChangeLayoutMode(true);">Personalize</a> <a href="javascript:ChangeLayoutMode(null,true);">Save</a> These functions are available in a Javascript file which SharePoint includes by default. So you just have to place this html on your page and there you go.

Config file for SharePoint custom timer jobs

Image
SharePoint timer jobs run under the OWSTIMER.exe process. This process has a configuration file associated with it. We can use this config file to specify the configuration settings that are to be used in custom timer jobs. Open the OWSTIMER.EXE.CONFIG and add the <appSettings> tag to it. Then add your key value pairs under this appSettings tag For this you have to add a reference to System.Configuration Then you can use the  System.Configuration. ConfigurationManager .AppSettings[ key ]  to retrieve the values for a key from the config file. Example:  string dept = System.Configuration. ConfigurationManager .AppSettings[ "Department" ];

Create User Profiles using SharePoint Object Model

In this post i will show you how you can use the SharePoint object model to create User Profiles programmatically. For the code to work make sure you have a User Profile Service application created and associated to your web application. You have to add references to two assemblies which will be available in the 14 hive/ISAPI Microsoft.Office.Server Microsoft.Office.Server.UserProfiles You have to get the ServiceContext first and then get the UserProfileManager from the service context. The UserProfileManager provides ways to add and edit profile to your SharePoint. string  socialDataStatsSite = "http://servename:port/" ; using ( SPSite siteColl = new SPSite (socialDataStatsSite)) { SPServiceContext serviceContext = SPServiceContext .GetContext(siteColl); UserProfileManager userProfileManager = new UserProfileManager (serviceContext); UserProfile profile = null ; bool existingUser = userProfileManager.UserExists(AccountName); if (existingUser) { profile = userPr...

Windows 7/Windows Server 2008 R2 SP1 released

Microsoft has released the Service Pack -1 for Windows 7 and Windows Server 2008 R2. The main feature in Windows Server 2008 R2 SP1 being the addition of RemoteFX. RemoteFX is a feature which enables rich user experience for Remote Desktop users. It enables rich interfaces with the utilization of GPU on the host. This means that remote desktop users can have a full blown Windows desktop experience remotely even from a thin client just as complex as a LCD display.The GPU on the server is shared among all the clients with the RemoteFX technology called VGPU(Virtual Graphical Processing Unit). The remote users can have all the rich experience of Sliverlight or 3D graphics from the client utilizing the VGPU. With the huge adoption of cloud by multiple organizations, Microsoft has yet again made a break through with RemoteFX by enabling the remote users to have rich User Experience which is the foremost requirement for an end user. With this great leap i expect more virtualization and mor...

Handle Session Start for SharePoint 2010 applications

Image
I ran into a situation where i have to handle the session start of a SharePoint application. I dint find much information about it in the internet, so i decided to post one myself. There are two main steps for this. 1. Enable sessions for your SharePoint application 2. Handle the Session_Start event. To enable Sessions for SharePoint application, make the following changes in your web.config 1. Make enableSessionState= true 2. Replace the <httpModules/> with the below       <httpModules >            <add name="Session" type="System.Web.SessionState.SessionStateModule" />       </httpModules > 3. Add the Session module for your SharePoint site from the IIS Manager.     Open IIS Manager and expand sites.     Select your site and double click on Modules. Click on Add Managed Module on the right hand side Actions menu Give a name to the module and s...

Run Visual Studio 2010 as administrator

Image
To create SharePoint projects in Visual Studio, we need to run it as administrator. I find it cumbersome to right click on the icon and click on run as administrator. So i figured out a way to run the Visual Studio 2010 as administrator whenever it is started. For this go to properties on Visual Studio icon. Go to the Compatibility tab and check Run this program as administrator The next time you click on Visual Studio 2010 icon, it will run with the administrator privileges.

Using Resource files with SharePoint

Image
This post will explain how resource files can be used while creating visual web parts for SharePoint. For this i will create a project which will have a drop down with two languages English and French. It will also have a text box and label associated to it which asks for a name. When i select a language from the drop down, the text in the label will change according to the language selected. I will start off with creating a visual web part using Visual Studio 2010. The design view is shown below Then i will add two new resource files to this project, English.resx and French.resx Then i will add the key value pairs to the resource files. I will name the key as lblName and the value of it will be Name in the English resource file. In the French resource file, the key will remain the same lblName, but the value will be the french translation for name i. e Nom This is how the English.resx resource file looks like And this is how French.resx looks like I will handle the s...