Search This Blog

Friday, November 27, 2015

How to read web.config appsettings or connection strings from .aspx file

How to read web.config appsettings or connection strings from .aspx file

Web.Config:

<appSettings><
add key="appSettingsKey" value="Testing Input"/></appSettings>
<connectionStrings><
add name="con_string" connectionString="Data Source=TestServer;Initial Catalog=TestDB;Integrated Security=SSPI" providerName="System.Data.SqlClient"/></connectionStrings>

.aspx Page

<asp:TextBox ID="txtAppSetting" runat="server" Text="<%$appSettings:appSettingsKey %>"></asp:TextBox>
<asp:TextBox ID="txtConnectionString" runat="server" Text="<%$connectionStrings:con_string %>"></asp:TextBox>

by using <%$appSettings:appSettingsKey %> , we can read the app settings data of Web.Config
Post a Comment

Popular Posts