的Web.config:
<div id="content">
<div id="area">
<div id="bottom">bottom</div>
<div id="middle">middle</div>
<div id="top">top</div>
</div>
</div>
ASP.net:
<appSettings file="Application.config">
<add key="stringC" value="Data Source=svr1;Initial Catalog=myDB;Integrated Security=FALSE;user=user2;pwd=@#$123pop;" />
</appSettings>
如何使用应用程序密钥替换<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ {HOW TO USE THE APP SETTINGS KEY HERE} %>"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors]" />
。
答案 0 :(得分:3)
您可以使用<%$ ConfigurationSettings.AppSettings["stringC"] %>
。
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConfigurationSettings.AppSettings["stringC"] %>"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors]" />
答案 1 :(得分:3)
在aspx
中,您需要以下内容
ConnectionString="<%$ appSettings:stringC %>"