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 have a user control which is deployed as a web part by using SmartPart.

I would now like to be able to define a property and have the value stored in the user's storage space. I guess I need to be able to trigger the dirty flag (SetPersonalizationDirty()) somehow when the property is changed programmatically.

How should I do this?

share|improve this question
up vote 1 down vote accepted

I don't believe the SmartPart is built to support your requirement and you'd need to do one of two things:

  • Create your own webpart from scratch that calls the ascx, passing it the personalized property
  • Extend the smartpart, customising the piece that loads the ascx, passing it the personalized property

To me, it sounds like a good time to move beyond the smartpart. It's pretty simple to create a webpart that loads a usercontrol anyways.

This article on msdn talks includes samples and guidance on how to support personalization in a webpart. Your custom property will look something like the code below:

// Create a custom category in the property sheet.
[Category("Custom Properties")]
// Assign the default value.
// Property is available in both Personalization
// and Customization mode.
// The caption that appears in the property sheet.
[FriendlyNameAttribute("Custom String")]
// The tool tip that appears when pausing the mouse pointer over
// the friendly name in the property pane.
[Description("Type a string value.")]
// Display the property in the property pane.
// The accessor for this property.
public string MyString
        return _myString;
        _myString = value;
share|improve this answer
+1 thanks for the reply. I have been trying to do what you say. I thought it should be easy to load a user control but got nowhere with it. Kept getting errors like '/_usercontrols/xyz' not found. Or Security exceptions. Can you point me at a good walk-thru for this? Would appreciate it :-) – paul Jan 31 '11 at 14:05
Something like is pretty accurate. Alternatively… The principle is simple, you just need to make sure you're pointing to the right location (which can be tricky to figure out sometimes. A little trial and error should sort it out. – Neil Richards Jan 31 '11 at 14:57

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.