Thursday, January 10, 2013

WebPart Custom Properties For "Site Url","List Url","Item Url" Etc

Web Part Custom Properties For "Site URL","List URL","Item URL" Etc


WebPart.CS file

protected override void CreateChildControls()
        {
            CAFUserControl control = Page.LoadControl(_ascxPath) as CAFUserControl;

            if (control != null)
            {
                control.WebPart = this;
            }

            Controls.Add(control);
       }

        [WebBrowsable(true), Category("CAF Properties"), Personalizable(PersonalizationScope.Shared), WebDisplayName("Enter OEM list name")]
        public String OEMListName { get; set; }

        [WebBrowsable(true), Category("CAF Properties"), Personalizable(PersonalizationScope.Shared), WebDisplayName("Enter Licensing list name")]
        public String LicensingListName { get; set; }

        [WebBrowsable(true), Category("CAF Properties"), Personalizable(PersonalizationScope.Shared), WebDisplayName("Enter Purchasing list name")]
        public String PurchasingListName { get; set; } 


UserControl.aspx.cs file

public partial class CAFUserControl : UserControl
    {
public CAF WebPart { get; set; }
}

Eg: ascx Path ( @"~/_CONTROLTEMPLATES/...." )
  private const string _ascxPath = @"~/_CONTROLTEMPLATES/AmexCalendar_VWP/AmexCalendar_VisualWebPart/AmexCalendar_VisualWebPartUserControl.ascx";

No comments:

Post a Comment