This web part mainly whenever u want use user control in webpart ,just use this webpart.
please find the below code.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.ComponentModel;
namespace Newcontentpages
{
[Guid("f0c50637-892b-4f6d-a42e-bc2546d1876f")]
public class Newcontentpage : System.Web.UI.WebControls.WebParts.WebPart
{
private string _cPath;
[Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Contentpage Webpart"),
WebDescription("Enter the control path"),
Category("ContentPage Properties")]
public string CPATH
{
get { return _cPath; }
set { _cPath = value; }
}
protected override void CreateChildControls()
{
// this.Controls.Add(Page.LoadControl(@"/_CONTROLTEMPLATES/cotentpages/ContentPages.ascx"));
if (!string.IsNullOrEmpty(CPATH))
{
this.Controls.Add(Page.LoadControl(CPATH));
}
}
}
}
once u can deployed this web u will get one custom property with text box there u can enter the user contro path.
please find the below code.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.ComponentModel;
namespace Newcontentpages
{
[Guid("f0c50637-892b-4f6d-a42e-bc2546d1876f")]
public class Newcontentpage : System.Web.UI.WebControls.WebParts.WebPart
{
private string _cPath;
[Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Contentpage Webpart"),
WebDescription("Enter the control path"),
Category("ContentPage Properties")]
public string CPATH
{
get { return _cPath; }
set { _cPath = value; }
}
protected override void CreateChildControls()
{
// this.Controls.Add(Page.LoadControl(@"/_CONTROLTEMPLATES/cotentpages/ContentPages.ascx"));
if (!string.IsNullOrEmpty(CPATH))
{
this.Controls.Add(Page.LoadControl(CPATH));
}
}
}
}
once u can deployed this web u will get one custom property with text box there u can enter the user contro path.



No comments:
Post a Comment