SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I created an webpart, and I've added a custom property. The webpart works fine.

Now I want to add this webpart in another page also, but with a different property value. The problem is that if I set the property value it will update all the values in all the webparts of this type in my site.

What should I do?

Here is my code:

public class ListWebPart : WebPart
    public static string List;
    [Category("Extended Settings"),
    WebDescription("Please Enter a Sample List"),


PS: Shorty scenario If you add a web part in page 1 and set the title: Webpartbla than you add the same web part in another page and set the title: webpartbla1 it will remember this values of the same webpart in different pages. This won't work with custom properties, like the one above

share|improve this question
up vote 4 down vote accepted

Don't make property List static


Working code:

public class MyDetailWebPart : WebPart {
  public string Code { get; set; }
  protected override void CreateChildControls()
        var control = (MyControl)Page.LoadControl(_ascxPath);
        control.Code = Code;

public partial class MyControl : UserControl
  public string Code { get; set; }
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.