How to create Custom WebPart and upload into SharePoint site:
In this article I'm trying to explain how to create WebPart and how to use that WebPart in SharePoint application. During this we can understood how to work with Custom WebParts.
WebParts are introduced in SharePoint in the year of 2003. From there onwards in ASP.net application also MicroSoft introduces to prepare our own Custom WebParts. Now, we discuss about Custom WebParts and what happen if we use that WebParts in our Site. Using WebPart we can reuse the code logic in our Application and perform the task throughout the Site. For example, in my site I have around 100+ Pages. I want to perform one task that is I want to display the mail information based on login user in all throughout the site in that case I just prepare one Custom WebPart and use that WebPart in SharePoint site. Then automatically that mail information will appear throughout the site.
How to Develop Custom WebPart:
Now, I'm trying to explain how to develop Custom WebPart using SharePoint Package.
Follow below steps to achieve your goal.
Open your project and then right click on solution explorer then choose Add->NewItem as shown in below fig.
Then choose SharePoint and then version of that then choose Visual Web Part then give a name for that and then click on Add button for adding WebPart to our project, as shown in below fig.
Once WebPart added to our project then design WebPart as you need then deploy the solution. In my example I just simply drag and drop one label control and then I give text for that label control, as shown in below fig.
Once deployed that SharePoint Solution then we can able to access that WebPart into our SharePoint site using Custom WebPart option.
How to Import Custom WebPart into SharePoint Site:
Now, I want to Import my Visual WebPart into my SharePoint site.
Follow below steps to achieve our goal.
Open your site Home Page and then choosePage option as shown in below fig and then choose Edit option for editing that site information.
After clicking edit option then a new Editing Tools will be enabled there you just choose Insert option then choose WebPart as highlighted in below figure.
Once you choose WebPart option then it will list out what are the WebParts available in the site then choose Custom option in Categories then choose your Custom WebPart available in the list then click on Add button for adding WebPart to our site.
Once you click on Add button then it will load for adding the Custom WebPart to your site. As shown in below figure.
After completion of loading then check the site our custom WebPart is appear in the site or not.
If we want to do some changes in that WebPart hen move the cursor to above of that WebPart then one dropdown will appear then select that then a list of actions will appear then choose whatever you need and perform the action into that.
Now, I choose Edit WebPart option then a new window will appear for editing purpose edit that information then do save changes it will automatically appear in our Site.
Hope this article will help you those who are looking for the same and those who are beginners to perform the same task.