Getting url from web.config

I try to save the url in the config file, but it does not work when I extract the url from the file

Below is my code

In web.config I have

<add key="URL" value="/NG/Viewer/ViewerSummary.aspx"/> 

On 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 the window opens if I do it below the 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 a window by placing a value in a configuration file?
Any help is appreciated.

Thanks.

+4
source share
3 answers

Perhaps your code you inserted has a couple of errors. The first mistake is that you are missing the opening single quote in the window.open call. Another mistake is that you are not actually using the url variable.

Try the following:

 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');"; 
+6
source
 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); 
0
source

See the article below to use the URLEncode method.

http://msdn.microsoft.com/en-us/library/zttxte6w.aspx

0
source

All Articles