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 want to change a string inside my Code using the customization for the WebPart.

Currently I created a custom WebPart Property like this:

[WebBrowsable(true), Category("Miscellaneous"), Personalizable(PersonalizationScope.Shared), WebDisplayName("Which Section you want to read?")] public string sectionToRead { get; set; }

My method is reading one whole section from the User Profile Details of a single user. I want to dynamically change the section which is read. So the idea was to create a custom property which writes a string to my code and according to that string I can determine which section is read.

The head for the method works like this: public Dictionary<string, string> GetUserCVProperties(string sectionName)

They Key for my dictionary is the ID of the user profile property and the value is the stored data from the given user.

My Problem is that I have created the custom property for "Edit WebPart" but if I'm changing the Value of the string nothing changes.

I'm calling the string of the custom property like this: this.WebPart.sectionToRead = "CV"; string sectionName = this.WebPart.sectionToRead.ToString();

Probably the error is that the hard coded string "CV" doesn't allow any changes. On the other hand my method is in need of that information or else my WebPart crashes because the parameter for the method is not given.

share|improve this question
up vote 0 down vote accepted

i solved the problem with some changes in my code.. now it looks like this:

Dictionary<string, string> cvProps = GetUserCVProperties(!String.IsNullOrEmpty(this.WebPart.sectionToRead) ? this.WebPart.sectionToRead : "CV");

everything else stayed the same instead of the last two code examples of course..

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.