call vbscript function from asp

I have been working on this for hours now, trying to debug my code, but I can't find the problem. I have a vbscript function defined as follows:
<html>
<head>
<title>Testing ASP</title>

<script language="vbscript">

Function GetURL()
dim URL_var
URL_var = window.location.search
GetURL = URL_var
</script>
</head>
<body>
...
</body>
</html>
In the body I have some ASP code that I would like to use to gather the information on the page. When I am initializing my variables, one of the items I need is the URI (above I am able to get it with window.location.search).

When I initialize my variable to hold the code it gives me an error. Below is how I initialize the code as well as the error:
<%
dim url_suffix
url_suffix = GetRUL()
...
%>
Error:

Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'GetURL'

I can not use javascript as we are trying to convert all our pages to vbscript in ASP (javascript is turned off all the blackberry's for security reasons therefore another solution has to be developed, ie ASP). when I used javascript, it worked fine by simply assigning the windows.location.search to the variable. But since ASP does not have the same function (that I have been able to find, anyways) for the windows.location.search, I am forced to try and call a function and return a variable that has this info in it. I have also tried cstr to convert the windows.location.search to a string to see if that helped... nothing changed.

Any help is appreciated.
dev_workAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brad2575Commented:
you do not have an "End Function" after the function

Function GetURL()
dim URL_var
URL_var = window.location.search
GetURL = URL_var
End Function
0
dev_workAuthor Commented:
Actually I did have the end function, I just missed adding it to the question... sorry.
0
hieloCommented:
What you are doing will NOT work. This:

<script language="vbscript">
...
</script> 
causes Function GetURL() to exist on the browser only after you have requested the page. The important thing to notice is that it exists/executes on the browser.  
This, however:
<%
dim url_suffix
url_suffix = GetRUL()
...
%> 
executes on the server BEFORE the browser page finishes loading. The browser cannot execute any server function nor vice-versa. You need to make/declare the function within the <% %> tags so that it executes on the server. However window.location.search IS a browser object, so you still cannot use that. Instead you can use:
Request.Querystring

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

dev_workAuthor Commented:
Do I have to provide a key for Request.QueryString(key) to work? I want to retrieve the whole QueryString and parse it with the code that I already have and works.

I knew that the vbscript code did render on the client side and the asp on the server side. I just thought that since the vbscript was in the <head> tag it would stay in memory to be used. However, now that I think about it, how can the server see the code that is in memory on my machine... :P

After I get this QueryString to work, I will accept the solution.

Thanks
0
brad2575Commented:
if you are just trying to get the current pages url you can do this with the Request.ServerVariable("") in ASP.

Here is a link to all the options you may need.

http://www.powerasp.com/content/new/get-current-page-url.asp
0
dev_workAuthor Commented:
Thank you for your help. I am used to using vbscript and javascript, but relatively new to asp. Your help has saved me big time and I really appreciate it!

Cheers!
0
hieloCommented:
glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.