在我的aspx.cs页面中,我有以下代码string url = ConfigurationManager.AppSettings["URL"];string strScript">
我正尝试在配置文件中存储URL,但在从文件中检索URL时无法正常工作
下面是我的代码
在web.config中,我有
<add key="URL" value="/NG/Viewer/ViewerSummary.aspx"/>
在我的aspx.cs页面中,我有以下代码
string url = ConfigurationManager.AppSettings["URL"];
string strScript = "window.open(url?QueryID=" + QueryId + "', '_blank','height=650, center:yes, width=800, status=no, resizable= yes, menubar=no, toolbar=no, location=yes, scrollbars=yes, status=no');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "strScript", strScript, true);
如果我写上面的代码,窗口不会打开,但如果我写下面的代码,窗口就会打开。
string strScript = "window.open('/NG/Viewer/ViewerSummary.aspx?QueryID=" + QueryId + "', '_blank','height=650, center:yes, width=800, status=no, resizable= yes, menubar=no, toolbar=no, location=yes, scrollbars=yes, status=no');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "strScript", strScript, true);
如何通过将值放入配置文件来打开窗口?
任何帮助都是非常感谢的。
谢谢。
发布于 2012-12-11 17:38:25
可能是您粘贴的代码有几个错误。第一个错误是在对window.open的调用中缺少左单引号。另一个错误是您实际上没有使用url
变量。
试试这个:
string strScript = "window.open('" + url + "?QueryID=" + QueryId + "', '_blank','height=650, center:yes, width=800, status=no, resizable= yes, menubar=no, toolbar=no, location=yes, scrollbars=yes, status=no');";
发布于 2012-12-11 17:38:31
string strScript = "window.open('" + url + "?QueryID=" + QueryId + "', '_blank','height=650, center:yes, width=800, status=no, resizable= yes, menubar=no, toolbar=no, location=yes, scrollbars=yes, status=no');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "strScript", strScript, true);
发布于 2012-12-11 17:39:33
有关使用URLEncode方法的信息,请参阅下面列出的文章。
https://stackoverflow.com/questions/13825489
复制