Attention: We are retiring the ASP.NET Community Blogs. Learn more >

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!

2 Comments

Comments have been disabled for this content.