Last post Sep 01, 2011 04:04 PM by swartzbill2000
Aug 30, 2011 04:11 PM|swartzbill2000|LINK
I have a custom server control derived from SqlDataSource. It is in a dll. I reference the dll in a web site. In the ctor, I want to get a connection string from web.config. I have tried
ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
When I drop an instance of the control on a web form, I get the error "Object reference not set to an instance of an object.". I seems like the control can't read web.config.
How can I read a connection string from web.config in a custom server control at design time?
Aug 31, 2011 02:33 AM|lohumi|LINK
When you invoke any methods from the DLL, you should pass the connection string to it as an object:
Please refer here..
Aug 31, 2011 11:03 PM|Decker Dong - MSFT|LINK
I think you should import the dll control into your test proj, and in your test proj there's a web.config with the configured connectionString tags.
Sep 01, 2011 04:04 PM|swartzbill2000|LINK
I now access the connection string in the Init handler. It seems to work