Request Object

G

Guest

I am trying to access in Javascript within an ASP.NET web page the Request
Object. I am specifically trying to access the values in the
Request.QueryString. When I try to access the values I get an error
specifying that the Request object is undefined... The Jscript code is as
follows:

alert(Request.QueryString("CASE")[1]);

In any thoughts or am Is my syntax incorrect. I need to be able to access
the QueryString from within jscript...

Thanks in advance
 
L

Lucas Tam

alert(Request.QueryString("CASE")[1]);

In any thoughts or am Is my syntax incorrect. I need to be able to
access the QueryString from within jscript...

In basic javascript ... there is no request object. You need to parse the
query string yourself.

But maybe Microsoft's Jscript has an extension?
 
G

Guest

How do you get that information otherwise then using the Request Object? So
there is another way besides using the Request Object? If there is does
anyone know how? I would greatly appreciate it.

thanks

Lucas Tam said:
alert(Request.QueryString("CASE")[1]);

In any thoughts or am Is my syntax incorrect. I need to be able to
access the QueryString from within jscript...

In basic javascript ... there is no request object. You need to parse the
query string yourself.

But maybe Microsoft's Jscript has an extension?

--
Lucas Tam ([email protected])
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
 
K

Kevin Spencer

JavaScript is on the client side. The client sends an HTTP Request to the
server. The server side classes can see the Request. They send a Response to
the client as a Web Page. So, JavaScript is client-side, and ASP.Net is
server-side, and never the twain shall meet. All they can do is send
messages back and forth, via Request and Response.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

Angel said:
How do you get that information otherwise then using the Request Object?
So
there is another way besides using the Request Object? If there is does
anyone know how? I would greatly appreciate it.

thanks

Lucas Tam said:
alert(Request.QueryString("CASE")[1]);

In any thoughts or am Is my syntax incorrect. I need to be able to
access the QueryString from within jscript...

In basic javascript ... there is no request object. You need to parse the
query string yourself.

But maybe Microsoft's Jscript has an extension?

--
Lucas Tam ([email protected])
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
 
J

JIMCO Software

Kevin said:
JavaScript is on the client side. The client sends an HTTP Request to
the server. The server side classes can see the Request. They send a
Response to the client as a Web Page. So, JavaScript is client-side,
and ASP.Net is server-side, and never the twain shall meet. All they
can do is send messages back and forth, via Request and Response.

Although you could look into AJAX or XMLHttp to get the data.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 
C

clintonG

We can populate JavaScript variables using QueryString values on the server.
One example of how is shown by this VB example [1] at the very bottom of the
page.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://aspnet.4guysfromrolla.com/articles/030202-1.2.aspx




Angel said:
How do you get that information otherwise then using the Request Object?
So
there is another way besides using the Request Object? If there is does
anyone know how? I would greatly appreciate it.

thanks

Lucas Tam said:
alert(Request.QueryString("CASE")[1]);

In any thoughts or am Is my syntax incorrect. I need to be able to
access the QueryString from within jscript...

In basic javascript ... there is no request object. You need to parse the
query string yourself.

But maybe Microsoft's Jscript has an extension?

--
Lucas Tam ([email protected])
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
 
J

JIMCO Software

clintonG said:
We can populate JavaScript variables using QueryString values on the
server. One example of how is shown by this VB example [1] at the
very bottom of the page.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://aspnet.4guysfromrolla.com/articles/030202-1.2.aspx

That code obviously requires a postback. I think the original poster was
asking about how to avoid the postback.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 
L

Lucas Tam

Although you could look into AJAX or XMLHttp to get the data.

You can use this javascript function to parse the query string:

function getParameter(queryString, parameterName)
{
// Add "=" to the parameter name (i.e. parameterName=value)
var parameterName = parameterName + "=";
if ( queryString.length > 0 )
{
// Find the beginning of the string
begin = queryString.indexOf ( parameterName );
// If the parameter name is not found, skip it, otherwise
return the value
if ( begin != -1 )
{
// Add the length (integer) to the beginning
begin += parameterName.length;
// Multiple parameters are separated by the "&" sign
end = queryString.indexOf ( "&" , begin );
if ( end == -1 )
{
end = queryString.length
}
// Return the string
return unescape ( queryString.substring ( begin, end ) );
}
// Return "null" if no parameter has been found
return "null";
}
}

ScriptID = getParameter(window.top.location.search, "ScriptID");
 
C

clintonG

Why don't you look at the topic "2.0 beta 2: Disappearing Controls" to
determine if you can help me debug the problem I've described?

<%= Clinton Gallagher

JIMCO Software said:
clintonG said:
We can populate JavaScript variables using QueryString values on the
server. One example of how is shown by this VB example [1] at the
very bottom of the page.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://aspnet.4guysfromrolla.com/articles/030202-1.2.aspx

That code obviously requires a postback. I think the original poster was
asking about how to avoid the postback.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top