re:
!But how <%$ AppSettings:som ething %is working?
!which class is really used to read the file?
You don't need a specific class.
The $ syntax is built into the Configuration Manager workspace.
$, in this context, means *evaluate* the applicable section of web.config.
If you have :
<appSettings>
<add key="selectDocs " value="SELECT * FROM documents WHERE thereisdata ORDERBY CreationDate DESC"/>
</appSettings>
You can retrieve the value of that query with :
<asp:Literal runat="server" Text="<%$ AppSettings:sel ectDocs%>" /><br/>
If you have:
<connectionStri ngs>
<add name="NwindConn "
connectionStrin g="server=(loca l);trusted_conn ection=true;dat abase=northwind "
providerName="S ystem.Data.SqlC lient" />
</connectionStrin gs>
You can retrieve the value of that query with :
<asp:Literal runat="server" Text="<%$ ConnectionStrin gs:NwindConn%>" />
Of course, you could also transfer those values to text variables and use them in other forms.
Juan T. Llibre, asp.net MVP
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
=============== =============== ========
"Osamede Zhang" <os*****@163.co mwrote in message news:uC******** ******@TK2MSFTN GP06.phx.gbl...
Thanks for your reply,it's very useful,
But how <%$ AppSettings:som ething %is working? which class is really used to read the file?
"John Timney (MVP)" <x_****@timney. eclipse.co.uk>
>As Riki explained, but to add - its also bad practice as app settings is a collection which used
like this has to be iterated in its entirety to get that specific value from the file every time.
For performance it would be better if this was read at application start once and stored in the
application object for use each time.
Regards
John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Riki" <la**@mij.gerus twrote in message news:us******** ******@TK2MSFTN GP02.phx.gbl...
>>>
"Osamede Zhang" <os*****@163.co mwrote in message news:e8******** ******@TK2MSFTN GP02.phx.gbl...
I just can't understand what appSettings
means, how it work
It refers to a setting in the AppSettings section in the web.config file.
something refers to the name of the setting.
The entire expression is replaced by the value of the setting when the page is run.
Riki