PDA

View Full Version : How can I save the variable value in Request.QueryString


anakintang
10-20-2004, 01:17 PM
If other people request my ASP page with some parameters like http://xxxxx.asp?v1=a&v2=b

How can I save the value of v1 and v2 in local variables for later use? Seems like I can print them out using Response.wrtie() but can not save them. Does anybody know?

eRad
10-20-2004, 02:00 PM
Dim var1, var2
var1 = Request.QueryString("v1")
var2 = Request.QueryString("v1")
..


Within the current ASP page you can always refer to the variables with Request("varname"), so you don't really need to save them..

If you're trying to forward the variables onto another page, you should send them over using forms, or a global variable, or possibly with Session objects.

anakintang
10-20-2004, 02:18 PM
I define the global variables at the beginning of the page that contains the frameset and want to send value to pages inside the frame, but when i set variable=Request.QueryString("v1") and print it out later, is says the variable is undefined or just has the initial value instead of the one in request

eRad
10-20-2004, 02:25 PM
Are you sure the values are being passed to the frameset page itself?

And when you print do you refer to the global variable and not the Request variable?

anakintang
10-20-2004, 02:27 PM
I think I do, like "alert(global)"

but is says undefined

eRad
10-20-2004, 02:36 PM
How are you defining the global variables?

An article i found shows the same problem you had due to the variable declaration.

Try declaring the variable first, and then setting it
<script type='text/javascript'>
var x;
x = '<%=globalvar%>';
alert(x);
</script>

http://forums.devshed.com/archive/t-187655

anakintang
10-20-2004, 02:48 PM
I think the problem happens when I set Request.QueryString() to variable, coz if I set a static value to variable then it can be printed out in another page

eRad
10-20-2004, 02:51 PM
try printing out the querystring variable and see what you get...

anakintang
10-20-2004, 03:05 PM
If I use response.write(request.querystring("v1")) I can get the right value, but just can not set it to a variable, I don't know why

eRad
10-20-2004, 03:10 PM
Can we see some code?

anakintang
10-20-2004, 03:16 PM
This page is the page containing the frameset and I want to get the value from querystring and then pass it the pages inside the frames.

I want to put value into "initialWMS" and "initialLayer"

Thanks