Tuesday 24 November 2015

Learn SharePoint in 30 Days : Day 1 Part 5

Create a Hello WebPart Using Visual Studio 2010.

Step 1: Launch the Visual Studio 2010. On the File menu, click on New->Project.

 On the left panel, Select Visual C#, Sharepoint 2010. On the right panel, select Visual Web Part. Then, type the project and soluction name as well as the location.


Step 2: Specify the URL that the project will be deployed to.






Step 3: Add the following code to the file "VisualWebPart1UserControl.ascx.cs"


protected void Page_Load(object sender, EventArgs e)
{
            Label lb = new Label();
            lb.Text = "Hello world";
            this.Controls.Add(lb);
 }


Step 4: On the Solution Explorer, Right click on the Project and select Build. Right click on the project again and click on Deploy.


Step 5: Open the web browser and locate to your Sharepoint site. On Site Action menu, click on Edit Page. On Editing Tool tab, select Inser->Webpart




Step 6: Select Custom on Categories tab and click on the web part we've just created.




Then, click Add and then click on Save button on the left corner, we have the following result


No comments: