There is a way to read web.config settings inside an activex code? I need to set connectionstring inside my activex.
有一种方法可以读取activex代码中的web.config设置吗?我需要在activex中设置connectionstring。
1 个解决方案
#1
2
ActiveX controls run in the browser, hence they have no access to Web.config
.
ActiveX控件在浏览器中运行,因此无法访问Web.config。
What you can do is expose properties in your controls and then fill in those properties in your code behind (C#/VB.NET) or .ASPX pages. Server-side code does have access to Web.config
, so it can read the data from there and pass it on to the ActiveX controls by filling in the properties.
您可以做的是在控件中公开属性,然后在代码(C#/ VB.NET)或.ASPX页面中填写这些属性。服务器端代码可以访问Web.config,因此它可以从那里读取数据并通过填充属性将其传递给ActiveX控件。
Alternatively, you could write code in your ASP.NET page that generates client-side JavaScript, and this JavaScript can then fill in the ActiveX control's properties. It's the same thing, really, because you're always accessing the config file from your server-side code and passing on the data to the ActiveX control, either by generating HTML or by generating JavaScript.
或者,您可以在ASP.NET页面中编写生成客户端JavaScript的代码,然后此JavaScript可以填充ActiveX控件的属性。实际上,这是一回事,因为您总是从服务器端代码访问配置文件,并通过生成HTML或生成JavaScript将数据传递给ActiveX控件。
#1
2
ActiveX controls run in the browser, hence they have no access to Web.config
.
ActiveX控件在浏览器中运行,因此无法访问Web.config。
What you can do is expose properties in your controls and then fill in those properties in your code behind (C#/VB.NET) or .ASPX pages. Server-side code does have access to Web.config
, so it can read the data from there and pass it on to the ActiveX controls by filling in the properties.
您可以做的是在控件中公开属性,然后在代码(C#/ VB.NET)或.ASPX页面中填写这些属性。服务器端代码可以访问Web.config,因此它可以从那里读取数据并通过填充属性将其传递给ActiveX控件。
Alternatively, you could write code in your ASP.NET page that generates client-side JavaScript, and this JavaScript can then fill in the ActiveX control's properties. It's the same thing, really, because you're always accessing the config file from your server-side code and passing on the data to the ActiveX control, either by generating HTML or by generating JavaScript.
或者,您可以在ASP.NET页面中编写生成客户端JavaScript的代码,然后此JavaScript可以填充ActiveX控件的属性。实际上,这是一回事,因为您总是从服务器端代码访问配置文件,并通过生成HTML或生成JavaScript将数据传递给ActiveX控件。