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

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...