Solved

pass a query string on a buttonclick

Posted on 2001-09-14
6
206 Views
Last Modified: 2008-02-01
I have a query string and when i click a button, that query string should be passed as a URL for the next page in the same window... Using ......

Window.Location.href="asp1.asp?Title=<% =Request.QueryString("xyz") %>

This is an example of how i tried for a Title field from a database.

the error i encountered was "Unterminated String Constant"...

The eror code is 1033. I hope iam correct...If anyone can help me sure do mail me soon........


S.Ramanujam (ramanujam@clearexperts.com)clearExpertsSolutions (p) Ltd,
A3, "CEEBROS RANGAM",
No.11, Cenatoph Road,
Teynampet, Chennai - 18

Phone: +91-44-4334619(off)
       +91-44-4334634(off)
       +91-44-3722375(res)

0
Comment
Question by:ramanujamsampath
6 Comments
 
LVL 3

Expert Comment

by:bigbed
ID: 6482346
You have href="....
then you have another double-quoted string within it ("xyz"), and you don't have the terminating double-quote for the href attribute.

You need to escape the double-quotes in the QueryString("xyz") call, or use single-quotes there. And you need to add the closing double-quote.
Example using single-quote inside double-quotes (assuming single-quotes are legal in your ASP):
Window.Location.href="asp1.asp?Title=<% =Request.QueryString('xyz') %>"

0
 
LVL 5

Expert Comment

by:aryumin
ID: 6482364
Window.Location.href="asp1.asp?Title=<% =Server.URLEncode(Request.QueryString("xyz")) %>
0
 
LVL 5

Expert Comment

by:aryumin
ID: 6482372
Oops. Forget a closing quote :(
Window.Location.href="asp1.asp?Title=<% =Server.URLEncode(Request.QueryString("xyz")) %>";
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 6482846
and to make it valid javascript you need to lowercase it and href is not needed to SET the url:
window.location="asp1.asp?Title=<% =Server.URLEncode(Request.QueryString("xyz")) %>";

Michel
0
 

Author Comment

by:ramanujamsampath
ID: 6486651
Thanx a lot for a wonderful answer..... It really worked at the first trial itself...

Ai. Alevidae
Cheers

S.Ramanujam (ramanujam@clearexperts.com)clearExpertsSolutions (p) Ltd,
A3, "CEEBROS RANGAM",
No.11, Cenatoph Road,
Teynampet, Chennai - 18

Phone: +91-44-4334619(off)
       +91-44-4334634(off)
       +91-44-3722375(res)

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6486945
Sorry guys - just making a comment - not trying to poach the question

Michel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

895 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