views:

437

answers:

1

Hi,

I have a solution for ASP.NET pages to be deployed to SharePoint that uses SqlDataSources on a few of the pages. Since with the SharePoint deployment the web.config file that is associated with our application (deployed to GAC) is the web.config for the SharePoint server, we do not have full access for all environments to change the web.config file and add connection strings. I then tried to create a global sealed class with a connection string variable and would like to set the connection string on the aspx page. I understand this could be done in code behind, but was wondering if there was a way to set it in the markup of the aspx page?

ex.

ConnectionString='<% CompanyABCGlobal.DBConnectionString %>'

I get the following error when attempting to do the above: Format of the initialization string does not conform to specification starting at index 0.

To do this in code behind, I would need to declare a protected property for every SqlDataSource and then would set the connection string property for each one.

Thanks for any feedback.

A: 

In order to access class properties you must use = or # declaration in the starting of expressions,i.e

ConnectionString = '<%# CompanyABCGlobal.DBConnectionString %>'

You can test it by opening <% expression after form tag if your class is available from that page.

For more information about expression msdn

Myra