Solved

Response.Write with querystring?

Posted on 2012-03-14
5
396 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
  • 2
  • 2
5 Comments
 
LVL 39

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 39

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now