In this snippet, we will see how to
read values which are defined in appsettings and connectionStrings sections of web.config in javascript using ASP.NET.
In the following code, we will add values for appSettings and connectionStrings
sections in web.coinfig file then from ASPX javascript we will try to read the
values.
Web.config
|
<appSettings>
<add key="appKeyPI" value="3.15"/>
</appSettings>
<connectionStrings>
<add name="conStr" connectionString="Here is my
connectoin string"/>
</connectionStrings>
|
ASPX Page
|
<head>
<script type="text/javascript">
var
appKeyVal = '<%=ConfigurationSettings.AppSettings["appKeyPI"].ToString()%>';
var
conStrVal = '<%=ConfigurationManager.ConnectionStrings["conStr"].ConnectionString
%>';
alert("AppSettings
value is: " + appKeyVal);
alert("Connection
string value is: " + conStrVal);
</script>
</head>
|
0 Comments:
Post a Comment