You must Sign In to post a response.
  • Category: ASP.NET

    Read app config settings in Html page

    Hi,

    I am trying to read config file and get those values in a HTML page (but not Asp.Net form).

    inside a script tag...

    var serverIP = '<%=ConfigurationManager.AppSettings["ServerIP"].ToString() %>'
    alert(serverIP);

    serverIP = 10.20.1.40 (set in app config)

    So I want to get alert on Html page as "10.20.1.40" But I am getting whole text (whatever is inside quotes) instead of only the value of only serverIP from app.config.

    Please let me know what is wrong in above code and please correct it.

    Thanks..
  • #769191
    What are you getting in return, whole text mean Complete Connection String starting with Data Source.... or anything else.
    -------------
    Glad to be,
    John Bhatt
    Editor - DNS Forums
    https://www.pyarb.com

  • #769192
    In alert ,I'm getting whole text whatever is there in single quote declared for var conn, but I need the value of myconnstring which is set in web.config (the value can be data source;dbname whatever).

  • #769210
    Add your code below <form id="form1" runat="server"> it will work


  • Sign In to post your comments