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
Add a comment
|
1 Answer
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 %>
3 Comments
inderpreet lahil
public string AssignedToText = ConfigurationManager.AppSettings["AssignedToText"]; do i add this to the Page_Load
Omar Himada
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 controlinderpreet lahil
Works like a charm! Thank you so much