0

In my properties I have a properties called Kompania and it is a dropdown properties. How can I retrieve the current properties for Kompania

Please help me!

1

2 Answers 2

1

To get the properties of a visual WebPart programmatically, you can refer to the following code for the WebPart at this article.

public enum CityEnum { Manila, Berlin, Auckland, Zurich };
public static CityEnum SampleDropDown;
[Category("Extended Settings"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Sample Drop Down"),
WebDescription("Please Choose a Sample DropDown")]
public CityEnum _SampleDropDown
{
    get { return SampleDropDown; }
    set { SampleDropDown = value; }
}

then on Page_Load() method use this line

Label1.Text = yourclass._SampleDropDown;
5
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Commented Jul 13, 2016 at 11:17
  • @Dikesh : ok will keep it in mind from next time. thanks for pointing it out.
    – DebugCode
    Commented Jul 13, 2016 at 11:19
  • useless for me! Commented Jul 13, 2016 at 13:02
  • useless ?? in what sense ?
    – DebugCode
    Commented Jul 13, 2016 at 13:35
  • @DebugCode after a deep study I realized that this was the exactly what I was looking for thank you Commented Jul 13, 2016 at 13:58
0

Add the following code below class definition.

[WebBrowsable(true),
WebDisplayName("Project ID"),
WebDescription("Enter Project Number"),
Personalizable(PersonalizationScope.Shared),
Category("Project Settings")]
public string ProjectID { get; set; }

To get the property value in code, you should use the “ProjectID” variable that defined as

public string ProjectID { get; set; }

You can also check detail steps at Create Custom WebPart Property for SharePoint Visual WebPart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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