Question

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.

Was it helpful?

Solution

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..

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top