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;}
}
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";
}
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:
Post a Comment