SIGN UP MEMBER LOGIN:    
ARTICLE

How to use User control as web part in share point

Posted by Destin joy Articles | SharePoint September 07, 2010
It is very easy to develop share point web part using User controls in ASP.net ic .ASCX file. If you use User control for share point development you can save a lot of time. Especially when dealing with design of the web part. I have attached the code for loading a user control please have a look
Reader Level:
Download Files:
 

It is very easy to develop share point web part using User controls in ASP.net ic .ASCX file. If you use User control for share point development you can save a lot of time. Especially when dealing with design of the web part. I have attached the code for loading a user control please have a look

This has two parts

I. Developing the User control

II. Loading user Control as Web part

First part is easy just use ASP.Net user control for your code

For the part II

1. First you have to put the user control (ASCX file and .CS file of User control)in _Layouts folder of share point .You can even create folder inside _Layouts and put your files there. Another way is you can place the ASCX file in _layouts and the .CS file you can publish as a dll and can place in BIN folder of the application

2. Then Go to Visual studio File->New Project then select Class Library as your project

sharepoint1.gif

3. Then Add share point reference

sharepoint2.gif

4. Add the below name spaces

  • using Microsoft.SharePoint;
  • using System.Web.UI;

  • using Microsoft.SharePoint.WebPartPages;

5. Add the path and name of your user control as shown below.Mine is Demo.ascx and I placed it unde Demo folder in layouts

sharepoint3.gif

6.
Don't forget to strong name if you are going to deploy this web part in GAC .

7. Now you have the webpart that will load the user control.Now you deploy this web part as normal as you do.
 

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor