February 22, 2012

VisualWebPart - Visual WebPart - Custom and EditPart Properties

http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/

private string customTextProp = "";

[WebBrowsable(true),
Category("Miscellaneous"),
Personalizable(PersonalizationScope.Shared),
WebDisplayName("Enter some text")]
public string CustomTextProp 

get{return customTextProp;}
set{customTextProp = value;
}


protected override void CreateChildControls()
{
   MyWebPartUserControl control = Page.LoadControl(_ascxPath) as MyWebPartUserControl;
   if (control != null)
      control.WebPart = this;
      Controls.Add(control);
   }
}



In UserControl.cs file
public MyWebPart WebPart { get; set; }

In 2007:

      Button btn = new Button();


        protected override void CreateChildControls()
        {
            btn.Text = "Set the Property";
            btn.Click += new EventHandler(btn_AddLink);
            this.Controls.Add(btn);
        }


        private void btn_AddLink(Object sender, EventArgs e)
        {
            btn.Text = "Changed Text";
        }

No comments:

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...