Hi. In a repeater I have as ItemTemplate the following, among others,
and everything works great:
<asp:SqlDataSource
ID="LocationSqlDataSource"
SelectCommand="SELECT blah-blah-blah"
EnableCaching="True"
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
CacheDuration="60"
FilterExpression="ID = {0}" RunAt="server">
<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkMeasureID"
PropertyName="Text" /> </FilterParameters>
</asp:SqlDataSource>
etc.
I have encrypted in Base64 the "OrderingProcess" which was
<add name="OrderingProcess" connectionString="server=xxx
\xxx;database=xxx;User ID=xxx;Password=xxx;"
providerName="System.Data.SqlClient" />
and the "ConnectionString" which was
<add key="ConnectionString" value="Data Source=xxx\xxx;Initial
Catalog=xxx;User ID=xxx;Password=xxx;"/>
and in the code-behind I have a function named DecryptSetting which
can be used as:
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderingProcess"))
The question is: how could I use this function in
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
above ?
I cannot say
ConnectionString="<%=
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderingProcess"))
%>"
In all the places in code behind where I needed the connection string,
I have used
Cache("ConnectionString") which has been set in App_Init as:
HttpContext.Current.Cache("ConnectionString") =
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("ConnectionString"))
Thanks a lot for your time and effort.
Alex. 5 6490
How about something like:
ConnectionString="<%$ DecryptSettings(ConnectionStrings:OrderingProcess) %>"
-- the syntax may not be exactly right, but this approach works fine with
many <%--%delimited items.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Radu" wrote:
Hi. In a repeater I have as ItemTemplate the following, among others,
and everything works great:
<asp:SqlDataSource
ID="LocationSqlDataSource"
SelectCommand="SELECT blah-blah-blah"
EnableCaching="True"
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
CacheDuration="60"
FilterExpression="ID = {0}" RunAt="server">
<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkMeasureID"
PropertyName="Text" /> </FilterParameters>
</asp:SqlDataSource>
etc.
I have encrypted in Base64 the "OrderingProcess" which was
<add name="OrderingProcess" connectionString="server=xxx
\xxx;database=xxx;User ID=xxx;Password=xxx;"
providerName="System.Data.SqlClient" />
and the "ConnectionString" which was
<add key="ConnectionString" value="Data Source=xxx\xxx;Initial
Catalog=xxx;User ID=xxx;Password=xxx;"/>
and in the code-behind I have a function named DecryptSetting which
can be used as:
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderingProcess"))
The question is: how could I use this function in
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
above ?
I cannot say
ConnectionString="<%=
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderingProcess"))
%>"
In all the places in code behind where I needed the connection string,
I have used
Cache("ConnectionString") which has been set in App_Init as:
HttpContext.Current.Cache("ConnectionString") =
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("ConnectionString"))
Thanks a lot for your time and effort.
Alex.
You could also create a public static (Shared in VB) function (in App_Code)
which will return decrypted connection string based on a string name
parameter, but will only read the config once per request and store them in a
Generic string dictionary for subsequent calls. Then you can either store the
dictionary in a static variable, or even application Cache.
Then from your aspx pages you could call this function similar to the
following:
ConnectionString="<%= GetMyConnect("OrderingProcess") %>
"Peter Bromberg [C# MVP]" wrote:
How about something like:
ConnectionString="<%$ DecryptSettings(ConnectionStrings:OrderingProcess) %>"
-- the syntax may not be exactly right, but this approach works fine with
many <%--%delimited items.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Radu" wrote:
Hi. In a repeater I have as ItemTemplate the following, among others,
and everything works great:
<asp:SqlDataSource
ID="LocationSqlDataSource"
SelectCommand="SELECT blah-blah-blah"
EnableCaching="True"
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
CacheDuration="60"
FilterExpression="ID = {0}" RunAt="server">
<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkMeasureID"
PropertyName="Text" /> </FilterParameters>
</asp:SqlDataSource>
etc.
I have encrypted in Base64 the "OrderingProcess" which was
<add name="OrderingProcess" connectionString="server=xxx
\xxx;database=xxx;User ID=xxx;Password=xxx;"
providerName="System.Data.SqlClient" />
and the "ConnectionString" which was
<add key="ConnectionString" value="Data Source=xxx\xxx;Initial
Catalog=xxx;User ID=xxx;Password=xxx;"/>
and in the code-behind I have a function named DecryptSetting which
can be used as:
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderingProcess"))
The question is: how could I use this function in
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
above ?
I cannot say
ConnectionString="<%=
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderingProcess"))
%>"
In all the places in code behind where I needed the connection string,
I have used
Cache("ConnectionString") which has been set in App_Init as:
HttpContext.Current.Cache("ConnectionString") =
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("ConnectionString"))
Thanks a lot for your time and effort.
Alex.
On May 14, 10:28 pm, Sergey Poberezovskiy
<SergeyPoberezovs...@discussions.microsoft.comwrot e:
You could also create a public static (Shared in VB) function (in App_Code)
which will return decrypted connection string based on a string name
parameter, but will only read the config once per request and store them in a
Generic string dictionary for subsequent calls. Then you can either storethe
dictionary in a static variable, or even application Cache.
Then from your aspx pages you could call this function similar to the
following:
ConnectionString="<%= GetMyConnect("OrderingProcess") %>
"Peter Bromberg [C# MVP]" wrote:
How about something like:
ConnectionString="<%$ DecryptSettings(ConnectionStrings:OrderingProcess) %>"
-- the syntax may not be exactly right, but this approach works fine with
many <%--%delimited items.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Radu" wrote:
Hi. In a repeater I have as ItemTemplate the following, among others,
and everything works great:
<asp:SqlDataSource
ID="LocationSqlDataSource"
SelectCommand="SELECT blah-blah-blah"
EnableCaching="True"
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
CacheDuration="60"
FilterExpression="ID = {0}" RunAt="server">
<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkMeasureID"
PropertyName="Text" / </FilterParameters>
</asp:SqlDataSource>
etc.
I have encrypted in Base64 the "OrderingProcess" which was
<add name="OrderingProcess" connectionString="server=xxx
\xxx;database=xxx;User ID=xxx;Password=xxx;"
providerName="System.Data.SqlClient" />
and the "ConnectionString" which was
<add key="ConnectionString" value="Data Source=xxx\xxx;Initial
Catalog=xxx;User ID=xxx;Password=xxx;"/>
and in the code-behind I have a function named DecryptSetting which
can be used as:
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("Order*ingProcess"))
The question is: how could I use this function in
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
above ?
I cannot say
ConnectionString="<%=
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("Order*ingProcess"))
%>"
In all the places in code behind where I needed the connection string,
I have used
Cache("ConnectionString") which has been set in App_Init as:
HttpContext.Current.Cache("ConnectionString") =
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("Conne*ctionString"))
Thanks a lot for your time and effort.
Alex.- Hide quoted text -
- Show quoted text -
Thank you for answering !
I have tried with
ConnectionString="<%=
DecryptSetting(ConnectionStrings:OrderingProcess) %>"
and it compiles, but when time comes to serve that page, I get
Keyword not supported: '<%'.
When I try with
ConnectionString="<%$
DecryptSetting(ConnectionStrings:CNOrderingProcess ) %>"
(the only change is the '$' sign instead of '='), then I get 98 errors
and warnings, all having NOTHING to do with the problem at hand
(example: Message 88 Could not find schema information for the
element 'http://schemas.microsoft.com/.NetConfiguration/
v2.0:customErrors'.) - thank you, compiler, but I also get the real
problem:
Error 90 The expression prefix 'DecryptSetting(ConnectionStrings'
was not recognized. Please correct the prefix or register the prefix
in the <expressionBuilderssection of configuration.
The function DecryptSetting is ultra-simple, in MAIN.vb in APP_CODE:
Public Function DecryptSetting(ByVal Source As String) As String
Dim data() As Byte = Convert.FromBase64String(Source)
Return System.Text.ASCIIEncoding.ASCII.GetString(data)
End Function
Thanks again
Alex.
Alex,
Quote from MSDN:
"The dollar sign ($) indicates to ASP.NET that an expression follows. The
expression prefix defines the type of expression, such as AppSettings,
ConnectionStrings, or Resources. Following the colon (:) is the actual
expression value that ASP.NET will resolve."
That is the reason why the compiler complains when you are trying <%$
Deccrypt ... your connection - it is not one of the predefined
If you want to call a function from HTML then you would use <%= syntax, but
then the parser will not recognize ConnectionStrings:MyStringName syntax
You could do something in between:
- declare your connection string in web.config as <add name="myName"
connectionString="myString" providerName="myProvider"
- call your shared function from html with <%= syntax passing the connection
name as the parameter: <%= MyDecrypt("myName") %>
- in decrypt function use ConfigurationManager to retrieve the connection
string
Public Shared Function MyDecrypt(cnName As String) As String
Dim result As String =
ConfigurationManager.ConnectionStrings(cnName).Con nectionString
' perform the decryption: result = decrypted(result)
Return result
End Function
There may be a better way to do it - but this should get you over the line.
Personally, I do not use DataSources - hence I am not the best source of
info on the topic.
Hope this helps
"Radu" wrote:
On May 14, 10:28 pm, Sergey Poberezovskiy
<SergeyPoberezovs...@discussions.microsoft.comwrot e:
You could also create a public static (Shared in VB) function (in App_Code)
which will return decrypted connection string based on a string name
parameter, but will only read the config once per request and store them in a
Generic string dictionary for subsequent calls. Then you can either store the
dictionary in a static variable, or even application Cache.
Then from your aspx pages you could call this function similar to the
following:
ConnectionString="<%= GetMyConnect("OrderingProcess") %>
"Peter Bromberg [C# MVP]" wrote:
How about something like:
ConnectionString="<%$ DecryptSettings(ConnectionStrings:OrderingProcess) %>"
-- the syntax may not be exactly right, but this approach works fine with
many <%--%delimited items.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Radu" wrote:
Hi. In a repeater I have as ItemTemplate the following, among others,
and everything works great:
<asp:SqlDataSource
ID="LocationSqlDataSource"
SelectCommand="SELECT blah-blah-blah"
EnableCaching="True"
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
CacheDuration="60"
FilterExpression="ID = {0}" RunAt="server">
<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkMeasureID"
PropertyName="Text" / </FilterParameters>
</asp:SqlDataSource>
etc.
I have encrypted in Base64 the "OrderingProcess" which was
<add name="OrderingProcess" connectionString="server=xxx
\xxx;database=xxx;User ID=xxx;Password=xxx;"
providerName="System.Data.SqlClient" />
and the "ConnectionString" which was
<add key="ConnectionString" value="Data Source=xxx\xxx;Initial
Catalog=xxx;User ID=xxx;Password=xxx;"/>
and in the code-behind I have a function named DecryptSetting which
can be used as:
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderÂ*ingProcess"))
The question is: how could I use this function in
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
above ?
I cannot say
ConnectionString="<%=
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("OrderÂ*ingProcess"))
%>"
In all the places in code behind where I needed the connection string,
I have used
Cache("ConnectionString") which has been set in App_Init as:
HttpContext.Current.Cache("ConnectionString") =
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("ConneÂ*ctionString"))
Thanks a lot for your time and effort.
Alex.- Hide quoted text -
- Show quoted text -
Thank you for answering !
I have tried with
ConnectionString="<%=
DecryptSetting(ConnectionStrings:OrderingProcess) %>"
and it compiles, but when time comes to serve that page, I get
Keyword not supported: '<%'.
When I try with
ConnectionString="<%$
DecryptSetting(ConnectionStrings:CNOrderingProcess ) %>"
(the only change is the '$' sign instead of '='), then I get 98 errors
and warnings, all having NOTHING to do with the problem at hand
(example: Message 88 Could not find schema information for the
element 'http://schemas.microsoft.com/.NetConfiguration/
v2.0:customErrors'.) - thank you, compiler, but I also get the real
problem:
Error 90 The expression prefix 'DecryptSetting(ConnectionStrings'
was not recognized. Please correct the prefix or register the prefix
in the <expressionBuilderssection of configuration.
The function DecryptSetting is ultra-simple, in MAIN.vb in APP_CODE:
Public Function DecryptSetting(ByVal Source As String) As String
Dim data() As Byte = Convert.FromBase64String(Source)
Return System.Text.ASCIIEncoding.ASCII.GetString(data)
End Function
Thanks again
Alex.
On May 15, 9:41 pm, Sergey Poberezovskiy
<SergeyPoberezovs...@discussions.microsoft.comwrot e:
Alex,
Quote from MSDN:
"The dollar sign ($) indicates to ASP.NET that an expression follows. The
expression prefix defines the type of expression, such as AppSettings,
ConnectionStrings, or Resources. Following the colon (:) is the actual
expression value that ASP.NET will resolve."
That is the reason why the compiler complains when you are trying <%$
Deccrypt ... your connection - it is not one of the predefined
If you want to call a function from HTML then you would use <%= syntax,but
then the parser will not recognize ConnectionStrings:MyStringName syntax
You could do something in between:
- declare your connection string in web.config as <add name="myName"
connectionString="myString" providerName="myProvider"
- call your shared function from html with <%= syntax passing the connection
name as the parameter: <%= MyDecrypt("myName") %>
- in decrypt function use ConfigurationManager to retrieve the connection
string
Public Shared Function MyDecrypt(cnName As String) As String
Dim result As String =
ConfigurationManager.ConnectionStrings(cnName).Con nectionString
' perform the decryption: result = decrypted(result)
Return result
End Function
There may be a better way to do it - but this should get you over the line.
Personally, I do not use DataSources - hence I am not the best source of
info on the topic.
Hope this helps
"Radu" wrote:
On May 14, 10:28 pm, Sergey Poberezovskiy
<SergeyPoberezovs...@discussions.microsoft.comwrot e:
You could also create a public static (Shared in VB) function (in App_Code)
which will return decrypted connection string based on a string name
parameter, but will only read the config once per request and store them in a
Generic string dictionary for subsequent calls. Then you can either store the
dictionary in a static variable, or even application Cache.
Then from your aspx pages you could call this function similar to the
following:
ConnectionString="<%= GetMyConnect("OrderingProcess") %>
"Peter Bromberg [C# MVP]" wrote:
How about something like:
ConnectionString="<%$ DecryptSettings(ConnectionStrings:OrderingProcess) %>"
-- the syntax may not be exactly right, but this approach works fine with
many <%--%delimited items.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Radu" wrote:
Hi. In a repeater I have as ItemTemplate the following, among others,
and everything works great:
<asp:SqlDataSource
ID="LocationSqlDataSource"
SelectCommand="SELECT blah-blah-blah"
EnableCaching="True"
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
CacheDuration="60"
FilterExpression="ID = {0}" RunAt="server">
<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkMeasureID"
PropertyName="Text" / </FilterParameters>
</asp:SqlDataSource>
etc.
I have encrypted in Base64 the "OrderingProcess" which was
<add name="OrderingProcess" connectionString="server=xxx
\xxx;database=xxx;User ID=xxx;Password=xxx;"
providerName="System.Data.SqlClient" />
and the "ConnectionString" which was
<add key="ConnectionString" value="Data Source=xxx\xxx;Initial
Catalog=xxx;User ID=xxx;Password=xxx;"/>
and in the code-behind I have a function named DecryptSetting which
can be used as:
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("Order**ingProcess"))
The question is: how could I use this function in
ConnectionString="<%$ ConnectionStrings:OrderingProcess %>"
above ?
I cannot say
ConnectionString="<%=
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("Order**ingProcess"))
%>"
In all the places in code behind where I needed the connection string,
I have used
Cache("ConnectionString") which has been set in App_Init as:
HttpContext.Current.Cache("ConnectionString") =
DecryptSetting(System.Configuration.ConfigurationM anager.AppSettings("Conne**ctionString"))
Thanks a lot for your time and effort.
Alex.- Hide quoted text -
- Show quoted text -
Thank you for answering !
I have tried with
ConnectionString="<%=
DecryptSetting(ConnectionStrings:OrderingProcess) %>"
and it compiles, but when time comes to serve that page, I get
Keyword not supported: '<%'.
When I try with
ConnectionString="<%$
DecryptSetting(ConnectionStrings:CNOrderingProcess ) %>"
(the only change is the '$' sign instead of '='), then I get 98 errors
and warnings, all having NOTHING to do with the problem at hand
(example: Message 88 Could not find schema information for the
element 'http://schemas.microsoft.com/.NetConfiguration/
v2.0:customErrors'.) - thank you, compiler, but I also get the real
problem:
Error 90 The expression prefix 'DecryptSetting(ConnectionStrings'
was not recognized. Please correct the prefix or register the prefix
in the <expressionBuilderssection of configuration.
The function DecryptSetting is ultra-simple, in MAIN.vb in APP_CODE:
Public Function DecryptSetting(ByVal Source As String) As String
Dim data() As Byte = Convert.FromBase64String(Source)
Return System.Text.ASCIIEncoding.ASCII.GetString(data)
End Function
Thanks again
Alex.- Hide quoted text -
- Show quoted text -
Thanks, you're right, this should work - it's logical. Thank you very
much.
Alex. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jim Andersen |
last post by:
Hi,
I would appreciate if someone could explain this behaviour, and maybe offer
a better solution.
I have been working with the GridView control. And SqlDataSource. It works
great if I do:...
|
by: coosa |
last post by:
Dear all,
I tried to replace the GridView Column's HyperLinkField
"DataNavigateUrlFormatString" property with a java script pop up
window, but wehen i preview the page, the link is REMOVED! Does...
|
by: tbh |
last post by:
is it possible in the ConnectionString of an asp:SqlDataSource construction
to refer to a variable i define at the top of my ASPX script and initialize,
for example, during Page_Init()?
(the...
|
by: Zeba |
last post by:
Hi,
Can you tell me how does the Eval function know where to find EventID
in the following code ?
Also, isn't this Eval function same as the DataBinder.Eval ? But MSDN
only shows Eval() to be...
|
by: tombow |
last post by:
I created a custom control (call it MyWidget) in a C# web control
library. MyWidget has a SqlDataSource property:
public abstract class MyWidget : WebControl
{
// .... snipped
private...
|
by: Jason Huang |
last post by:
Hi,
Here is the SqlDataSource in my aspx file
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:ETCServiceTestConnectionStringA %>"...
|
by: shapper |
last post by:
Hello,
I have a class where I created various controls.
One of the controls have a property which is a generic list of
WebControl.
Then in web site page I have something like:
Dim a As New...
|
by: Seth Williams |
last post by:
I have a sqlDataSource, using a stored procedure - the datasource is:
<asp:SqlDataSource ID="dsMembers" runat="server"
ConnectionString="<%$ ConnectionStrings:MainConnectionString %>"...
|
by: Eric |
last post by:
Hi,
i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable
Now, i tried the same in aspx file: i dragged a sqldatasource control and
changed...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |