Did you know you could directly use AppSettings on server controls (In 2.0)?

Now in 2.0, you could get value from AppSettings and you can assign them directly to server controls.

 

For example you have a configuration section as shown below

<appSettings>
         
<add key="CreatorEmail" value="Creator@Universe.COM"/>
</appSettings>

Then you could assign or use CreatorEmail against server control as <%$ AppSettings:CreatorEmail %>

 

A sample aspx file of using it would be as shown below: In below example I am assigning the value to a label control.


<%@ Page Language="VB" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<
script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

</script>

   <html xmlns="http://www.w3.org/1999/xhtml" >

   <head runat="server">

      <title>AppSettings Test Page</title>

   </head>

      <body>

      <form id="form1" runat="server">

      <div>
            <asp:Label ID="Label1" Runat="server" Text="<%$ AppSettings:CreatorEmail %>"></asp:Label>
      </div>

      </form>

      </body>

</html>

 

Hope it helps!

Published Monday, October 11, 2004 7:10 AM by SreedharK

Comments

# re: Did you know you could directly use AppSettings on server controls (In 2.0)?

Saturday, October 23, 2004 1:04 AM by Jon Galloway
Great tip! Thanks.

# re: Did you know you could directly use AppSettings on server controls (In 2.0)?

Monday, October 25, 2004 2:42 AM by Fredrik Normén
Maybe this post on my blog could be something for you, it’s also explaining the other new expressions and also how you can build your own expression:

http://fredrik.nsquared2.com/viewpost.aspx?PostID=161

# re: Did you know you could directly use AppSettings on server controls (In 2.0)?

Monday, October 25, 2004 7:16 AM by Sreedhar
I have tried it! I am posting very easy things which developers can easily understand and generally exites them!

Wanted to bring developers attention first to 2.0, once they had intrest, then they can do their own R&D :)





Leave a Comment

(required) 
(required) 
(optional)
(required)