在js文件中,获取webconfig中的配置信息

来源:互联网 发布:之前没cos过知乎 编辑:程序博客网 时间:2024/05/18 09:17

webconfig中的配置信息

    <!--默认押金-->    <add key="OverDueMoney" value="80" />

1.在客户端页面(非单独的js文件),可以直接获取webconfig的配置信息

function Name() {var Name=System.Web.Configuration.WebConfigurationManager.AppSettings["OverDueMoney"];}

2.在单独的js文件中,那该如何调用Webconfig?

2.1在前段页面中,可以直接自定个标签

  <input class="easyui-textbox" default-price="0" default-subsidies="0" type="text" default-value="<%=ConfigurationManager.AppSettings.AllKeys.Contains("OverDueMoney")%>"                                    name="OtherPrice" id="OtherPrice" />

2.2在js页面中,通过attr获取属性里面绑定的值

 var OverDueMoney = $("#OtherPrice").attr("default-value");
0 0