Tuesday 20 August 2019

How to access web.config settings directly in .aspx page?

///////////////////  In your web config file

<appSettings>
<add key="Key" value="this is test" />
</appSettings>



///////////////// In aspx file

<asp:TextBox ID = "txtBox1" runat = "server" Text="<%=System.Configuration.ConfigurationManager.AppSettings["Key"]%>" />


///////////////////////////// for the variable


<script type="text/javascript">
   $(document).ready(function () {
        var my1 = '<%=ConfigurationManager.AppSettings["Key"].ToString() %>';
               alert(my1);
     });
</script>

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...