Archive for October, 2008

(Really)Quick and Easy SharePoint webpart

// October 29th, 2008 // No Comments » // ASP.Net, Sharepoint, Visual Studio.Net

If you have been in a situation where things are in a big hairy mess, you probably would follow the process of elimination to ensure you are not chasing the wrong items down the rabbit hole.

Now consider you are working with SharePoint and you are in a tight spot as mentioned above. You probably want to ensure that WSS/MOSS has been configured properly and that the problem is not with the webpart you are working on, for example.

Here’s a quick and easy way of writing a “hello world” webpart that doesn’t involve features and layouts and WSPs and stsadm commands and etc.

1. Open up Visual Studio 2008 and create a new class library project (name it something unique, for example, DingDongBellWebPart) and add the following code in Class1.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Web.UI.WebControls.WebParts;

namespace DingDongBellWebPart

{

public class Class1 : WebPart

{

protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)

{

writer.Write(“DingDongBell test”);

base.Render(writer);

}

}

}

}

2. Check the “Sign the assembly” checkbox in Project properties “Signing” tab as shown below

Project properties

(Click on image above for better resolution)

3. Under “Choose a strong name key file” dropdownlist, select “New”.

4. Uncheck “Protect my key file with a password” as shown below

Create Strong Name Key

5. Give it a name and click OK.

6. Build the project.

7. Drag the project’s dll from the bin folder and drop it in C:\Windows\assembly folder. This registers the DLL in the GAC.

8. Replace the values for the attributes where necessary in the line below and add this line in the <SafeControls> section in the web.config file of the website you are trying to deploy this webpart to. (You can even try the SharePoint’s central admin’s web.config file. should work.)

<SafeControl Assembly=”DingDongBellWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1af588c27b5f26e0″ Namespace=”DingDongBellWebPart” TypeName=”*” Safe=”True” />

**NOTE**: Don’t forget to replace the PublicKeyToken above. There are multiple ways to fetch the PublicKeyToken of your DLL. Here’s one way. Go to C:\Windows\assembly and right click on your assembly and click properties as shown below.

Webpart properties

9. Visit the following URL – http://insert_your_website_url_here/_layouts/NewDwp.aspx [Of course replace "insert_your_website_url_here" with your value]

10. It should show up in that list as shown below. (I know….it says GirishWebpart.Class1 in the screenshot below instead of DingDongBellWebpart.Class1. May be it is because I figured GirishWebpart was a much better name than the ridiculous-sounding DingDongBellWebpart.)

Webpart properties

(Click on image above for better resolution)

11. If it doesn’t work, reset IIS. And try again. Should work.

12. Enjoy.

Shyju just had a baby boy

// October 7th, 2008 // No Comments » // Miscellaneous, Personal

Archith

My second sister Shyju brought Archith into this beautiful world on Friday, October 3rd 2008. He weighs 7.2 lbs.

More pics on my flickr soon…

MCPD

// October 5th, 2008 // 3 Comments » // ASP.Net, certification, Miscellaneous

MCPD That’s what I am now. An MCPD – an abbreviation for Microsoft Certified Professional Developer (Web).

I took exam 70-547 early today and scored 1000 out of 1000. LOL! Can you believe it? I scored 100%. Sometimes I surprise myself. ;)

So this, in addition to exams 70-528 and 70-536 that I had passed earlier this year, makes me an MCPD.

Yay! :D

MUST SEE – Super slow motion punches

// October 2nd, 2008 // 1 Comment » // Fun, LOL, Miscellaneous, WOW, Youtube

Today is Mahatma Gandhi’s birthday. So I figured I’ll post something about violence.

I know. I’m bored (and going to hell).