0

I am wanting to pull text from web.config. I have added the following code <add key ="AssignedToText" value="Please submit a ticket to assign any users to this specific group."/>to my web.config file. I want to display this text on the bottom of an ascx page. How can i go about doing so? How do code it into the ascx.cs file and how do I code it onto the ascx file

0

1 Answer 1

1

Use the ConfigurationManager to get keys from the web.config like this:

public string AssignedToText = ConfigurationManager.AppSettings["AssignedToText"];

Then in your .ascx page you can do this:

<%= AssignedToText %>
Sign up to request clarification or add additional context in comments.

3 Comments

public string AssignedToText = ConfigurationManager.AppSettings["AssignedToText"]; do i add this to the Page_Load
Declare it at the class level by making it public string ... in your .ascx.cs file, then your .ascx page will be able to see it. Set the value in Page_Load if you want, doesn't matter, so long as variable is declared at class level of the user control
Works like a charm! Thank you so much

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.