How to Create a Web Part in Sharepoint 2007

Here is the steps to create a basic web part in Sharepoint 2007

Creating Web Part:


1. Start - Run - type "devenv" - ok


2. File - New - Project - Visual C# Projects - Web Part Library


3. Location : "D:\sara\sharepoint\MyCode\"


4. Name : "Manasa" - OK


In the Solution Explorer


5. Rename WebPart1.cs into Sarovar.cs


6. Change the Class Name [ WebPart1 into Sarovar in Sarovar.cs ]


7. Rename web part [ Webpart1.dwp into Sarovar.dwp ]


8. Start - Programs - Visual studio 2003 - Visual Studio .Net Tools - Visual
Studio 2003 Command Prompt - Enter


9. go to d:\sara\sharepoint\MyCode\Manasa\bin


10. Type "sn -k a.snk" [ it will create strong name public key token ]


11. In the AssemblyInfo.cs,
change AssemblyKeyFile into [assembly: AssemblyKeyFile(".\\a.snk")]


12. In side Sarovar.cs,
Write the program.


TextBox t;
protected override void CreateChildControls()
{
t = new TextBox();
t.Text = "God is Now Here";
t.ForeColor = System.Drawing.Color.Blue;
this.Controls.Add (t);
}
protected override void RenderWebPart(HtmlTextWriter output)
{
RenderChildren(output);
}


13. Inside the manifest.xml pu the following code :





15. Press Shift + Ctrl + B -- to get Manasa.dll


16. Start - Run - Assembly


17. Explore "D:\sara\sharepoint\MyCode\Manasa\bin" folder


18. Drag and Drag manasa.dll into "c:\windows\assembly"


19. Goto "c:\windows\assembly" window
select "Manasa.dll" -- Right Click - Properties - select Public key
token - copy


20. Inside the Sarover.dwp,
Change webpart1 into Sarovar.
Type the following thing. and paste the public key token copied from
Mansa.dll in assembly folder [ GAC ]
Manasa,Version=1.0.2.600, Culture=neutral,
PublicKeyToken=77a58362fd626c9a



21. Goto C:\Inetpub\Vana
Open "Web.config" using TextPad - Click on the Agree Button


22. Paste the following line
/>


File - Save


23. Start - Run - InetMgr
Expand [ + ] REDPORTAL [ Local Computer ] and Application Pools


24. Click MSSharepointPortalAppPool - Right Click - Recycle


25. Click MSSharepointAppPool - Right Click - Recycle


26. Start - Run - IEXPLORE


26. Type http://localhost:9888 to logon to wokflowone


27. Type the userName and password [ portal8 & rediye2005 ]
Choose Premium, click Login


28. Click 'Sourcing'. If any webpart existing, please close all


29. Click on 'Modify Shared Page' -- Add web parts - import - Browse
Choose 'D:\sara\sharepoint\MyCode\Manasa\Sarovar.dwp'
Click 'Upload'


30. Drag and Drop 'Sarovar' webpart into Zone


31. You can see the textbox inside the zone.

No comments: