Friday, 12 February 2010

Unexpected property persistence in a web part

I’m writing a web part at the moment, which, to cut a long story short, tracks a bunch of properties between post-backs using view state as you might expect;


What I’ve found though is that if I add one of these web parts to my page and then use it so that CurrentPage is set to, say, 5 and then edit the web part configuration, this property gets persisted too - coming back to the page later defaults current page to 5! Is this a bug or does SharePoint insist on persisting all properties during configuration? Even though I haven’t added any attributes to tell it do so?

All I know is the only way I could get rid of this behaviour is to make the property protected or private, which isn’t a big deal, but it’s confusing that this happens at all.

No comments:

Post a Comment