如何在window.open函数ASP.NET中调用WebConfig appsetting值?

时间:2017-02-23 10:10:43

标签: javascript asp.net web-config window.open

<input id="Button1" type="button" value="button" onclick='window.open("https://google.com")' />

我必须使用webconfig appsettings更改此设置。

在webconfig中,我有

<add key="Google" value="https://google.com"/>

我必须使用密钥获取url webconfig。

我试过了

<input id="Button1" type="button" value="button" onclick='window.open("<%= ConfigurationManager.AppSettings["Google"] %>")' />

但它没有用。

你能找到一个解决方案来访问window.open函数中的webconfig appsettings值吗?

1 个答案:

答案 0 :(得分:0)

尝试在后面的代码中使用变量,例如

<th onclick="location.href='?edit=ID'">Item #1</th>

然后在页面

th[onclick]

编辑 - 根据想要在aspx页面本身进行的评论(不确定为什么要这样做,但我确定你有理由)。

@media not print {
    th[onclick], td[onclick] {
        color: #00e;
        text-decoration: underline;
        cursor: pointer;
    }
}