0

I have an attribute on a constant field like this:

[Privilege(SysCaption = "")]
public const string View_Course_IndexSelf = "View Course IndexSelf";

I need to fill SysCaption in the attribute with a value loaded from web.config.

How can I do this? Any help will be appreciated.

1
  • You can get a key from the web.config via the WebConfigurationManager: WebConfigurationManager.AppSettings["YourKeyHere"] Commented Jul 23, 2021 at 12:00

1 Answer 1

1

You can't change the value of an attribute at runtime, those values are hardcoded into the code.

You can, of course, use the attribute properties during execution to lookup other items of data that are dynamic.

In your case, the attribute property "SysCaption" could be set to a label or marker, that some other code ( I guess whatever the Privilege attribute is related to) will do the dynamic lookup.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.