Click here to Skip to main content
15,921,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

how to read values from web.config and use those values in static html.
i need to take value from web.config and display it in html.
Posted

 
Share this answer
 
Comments
revanthkumar.ch 16-May-12 7:33am    
i tried the procedure which has given in your second link,still it is not working.i think static html cant get values from web.config
you can find a good sample here

Read Configuration Settings of Web.config using Javascript[^]

query string in win forms[^]

Regards
Sebastian
 
Share this answer
 
v2
Comments
revanthkumar.ch 16-May-12 7:20am    
its working with dynamic webpages but not static html pages
Sebastian T Xavier 16-May-12 7:28am    
see the updated link
revanthkumar.ch 16-May-12 7:37am    
i didnt get u,i am asking about getting values from web.config to static html pages.not related to query string in win forms.
Hi

Add below example code in your web.config file

XML
</configSections>
<appSettings>
  <!--<add key="ConStr" value=" providerName=System.Data.SqlClient;Data Source=INTEL-PC\SQLEXPRESS;Initial Catalog=School_new;User ID=sa;Password=sa"/>
  <add key="ConnecStr" value="providerName=System.Data.SqlClient;Data Source=INTEL-PC\SQLEXPRESS;Initial Catalog=School_new;User ID=sa;Password=sa"/>-->
  </appSettings>
  <connectionStrings>



after that use belo header file and code to get value of variable.
using System.Configuration;  // Header File


DataUtil du = new DataUtil();
    public SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["School"].ConnectionString);

 //paste in code page
 
Share this answer
 
v2
Comments
revanthkumar.ch 16-May-12 7:19am    
i need to access the web.config values in static html page. not in dynamic webpage
Sebastian T Xavier 16-May-12 7:29am    
What does this answer with query-string?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900