1. Create a new C # class library.
2. Add system. Web refeerence.
3. AddCode
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. Web. UI;
Namespace helloworldwebpart
{
Public class myfirstwebpart: system. Web. UI. webcontrols. webparts. webpart
{
Protected override void render (htmltextwriter writer)
{
Writer. Write ("Hello World");
}
}
}
4. Modify project properties
Add a key. SNK to the project properties.
5. Modify assemblyinfo. CS and add the following code:
Using system. Security;
[Assembly: allowpartiallytrustedcallers]
6. recompile the DLL and copy the above DLL to: C: \ Inetpub \ wwwroot \ WSS \ virtualdirectories \ 26864 \ _ app_bin to modify the web. config, add the following code (using the refactor tool ):
7. Deploy the generated DLL to SharePoint. Select create.
8. Select "Web parts", select "new", select the Web part to be added, and click "populate Gallery ".
9. Select "Edit page" on a page and add the corresponding web part.