Solved

Response.Write with querystring?

Posted on 2012-03-14
5
402 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Video Tutorial help 2 38
SVG and IE11 2 17
StoredProcedure to JSON query faulty syntax 2 25
Building JSON/JQuery Results Display 11 25
Find out what you should include to make the best professional email signature for your organization.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 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