admin管理员组文章数量:1325361
I am trying to store a URL in the configuration file, but it does not work when I retrieve the URL from the file
Below is my code
In web.config, I have
<add key="URL" value="/NG/Viewer/ViewerSummary.aspx"/>
In my aspx.cs page, I have the following code
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);
the window does not open if I write the above code, but window opens if I do this below code.
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);
How can I open the window by putting the value in the config file?
Any help is appreciated.
Thanks.
I am trying to store a URL in the configuration file, but it does not work when I retrieve the URL from the file
Below is my code
In web.config, I have
<add key="URL" value="/NG/Viewer/ViewerSummary.aspx"/>
In my aspx.cs page, I have the following code
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);
the window does not open if I write the above code, but window opens if I do this below code.
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);
How can I open the window by putting the value in the config file?
Any help is appreciated.
Thanks.
Share Improve this question edited Oct 28, 2016 at 14:40 A1rPun 16.9k8 gold badges59 silver badges92 bronze badges asked Dec 11, 2012 at 17:35 Avinash ChandraAvinash Chandra 1831 gold badge9 silver badges24 bronze badges3 Answers
Reset to default 6It could be that your code that you have pasted has a couple errors. The first error is you're missing the opening single quote in the call to window.open. The other error is you aren't actually using the url
variable.
Try this:
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');";
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);
See the article listed below for using URLEncode method.
http://msdn.microsoft./en-us/library/zttxte6w.aspx
本文标签: cGetting a URL from webconfigStack Overflow
版权声明:本文标题:c# - Getting a URL from web.config - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742193815a2430706.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论