如何直接访问.aspx页面中web.config设置? [英] How to access web.config settings directly in .aspx page?

查看:437
本文介绍了如何直接访问.aspx页面中web.config设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个网页,它包含web.cofig例如某些设置值images.So我想给在该特定图像的src web.config文件,文件名的图像的路径。

我想读的设置仅在aspx页面没有codebehind。

例如

下面是我的code:

  Web.Config中:
<添加键=的ImagePath值=htt​​p://192.168.0.181/Labeling/Images//>

在我的aspx页面,

< IMG ID =ImgHeader=服务器SRC =<%ConfigurationManager.AppSettings [的ImagePath]%GT; />


解决方案

 < IMG ID =ImgHeader=服务器SRC =<%$ ConfigurationSettings.AppSettings [ 的ImagePath]%GT; />

应该做的伎俩。

I've created a web page and it contains some settings value in web.cofig for example images.So i want to give the path of images in Web.Config file and file name in that particular image src.

I wanted to read that settings only in aspx page not in codebehind.

For example

Below is my code:

Web.Config:
<add key="ImagePath" value="http://192.168.0.181/Labeling/Images/"/>

and in my aspx page,

<img id="ImgHeader" runat="server" src="<%ConfigurationManager.AppSettings["ImagePath"]%>" />

解决方案

<img id="ImgHeader" runat="server" src="<%$ ConfigurationSettings.AppSettings["ImagePath"] %>" />

Should do the trick.

这篇关于如何直接访问.aspx页面中web.config设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆