Solved

Response.Write with querystring?

Posted on 2012-03-14
5
408 Views
Last Modified: 2012-03-14
Can someone please help me figure out why I can get this to work:

Response.Write("<script>window.open('CCNew.asp','_top');</script>")

but not this:

Response.Write("<script>window.open('CCNew.asp?proxyfor=' & Request.querystring('proxyfor') & '&mode=' & Request.QueryString('mode')','_top');</script>")

TIA,
Andrew
0
Comment
Question by:Ahelbling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37721770
Window.Open is interpreting this:
'CCNew.asp?proxyfor='


try Repsonse.Write
(String.Format("<script>window.open('CCnew.asp?proxyfor={0}&mode={1}_top</script>", Request.querystring("proxyfor"),  Request.QueryString("mode")))



the {0} . . . {1} . . . {n} get replaced with the extra parameters after the string in order.
0
 

Author Comment

by:Ahelbling
ID: 37721796
hmmm...

Response.Write(String.Format("<script>window.open('CCnew.asp?proxyfor={0}&mode={1}_top</script>", Request.querystring("proxyfor"),  Request.QueryString("mode")))

Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: 'String'
0
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 200 total points
ID: 37721841
Response.Write(StringFormat("<script>window.open('CCnew.asp?proxyfor={0}&mode={1}_top')</script>", Request.querystring("proxyfor").ToString(),  Request.QueryString("mode").ToString()))

forgot to close the window.open . . . and added to String to the Request.QueryString parameters.


Also the query string is case sensitive.



Just saw this was ASP . . . thought it was vB.

add the following function (courtesy of http://www.codeproject.com/Articles/31432/String-Format-equivalent-for-ASP) and remove the "." from string.format.

Function StringFormat(sVal, aArgs)
Dim i
    For i=0 To UBound(aArgs)
        sVal = Replace(sVal,"{" & CStr(i) & "}",aArgs(i))
    Next
    StringFormat = sVal
End Function
0
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 300 total points
ID: 37721868
Response.Write("<script>window.open('currentPAge.aspx?proxyfor=" & Request.QueryString("proxyfor") & "&mode=" & Request.QueryString("mode") & "','_top');</script>")
0
 

Author Comment

by:Ahelbling
ID: 37721886
Thank you both!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question