Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2004, 10:43 AM
Authorized User
 
Join Date: Jul 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Submitting POST data without a form

Is it possible to send parameters from one ASP page to another in POST mode without a form? I know I can send data in GET mode simply by response.redirect("nextpage.asp?variablename=value "), but I need for the data to be sent in POST mode. Please tell me if that can be done, and how.

 
Old October 27th, 2004, 07:07 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I dont believe so. You want to 'post' data to page not using a form, why would you want to do this?

Are you aware:
1..You can send data from page to page using hidden forms?
2..You can have as many forms on a page as you like

Given this, the question why comes to mind again. Personaly I send data from page to page using one of the following three methods - in order of preferecne:

1..Request.form
2..Request.querystring
3..Sessions

Or perhaps you are using an upload object (or similar) that doesnt allow the request object to be used, in this case I would use the session object.

Wind is your friend
Matt
 
Old October 28th, 2004, 11:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, Matt is right.

takabyte, Can you explain on what EXACTLY you are trying to achieve?

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 29th, 2004, 12:02 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You can do this by using XMLHTTP object.

Here is a sample code. You can get a number of them from MSDN.

Dim obj_post
Set obj_post=Server.CreateObject("Msxml2.SERVERXMLHTTP ")
Dim str_data
str_data="field1=<value of field1>&field2=<value of field2>&field3=<value of field3>"
obj_post.Open "POST", "http://www.yoursite.com/actionpage.asp",False
obj_post.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
obj_post.Send str_data
If Err.Number <> 0 Then
    Response.Write("Your web site does not appear to be up right now. Please try again later.")
    Err.Clear
Else
    Response.write("data successfully posted<br />")
Endif
 
Old October 29th, 2004, 04:18 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Hi, Greetings to ALL

The solution from Madhukp is definetly correct but be aware of Browser Versioning and XML support on the browsers from non IE family if your site is internationallized.

Anubhav Kumar
 
Old October 29th, 2004, 06:40 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Dear Anubhav,

This is a server side XML. So, I think, there is no browser compatibility problem. Am I incorrect ?

This may not work when the correct XML parser library is not installed. This library is free to download from microsoft site.

I did not have a chance to test it with ASP 2.0. It is working correctly with ASP 3.0 and msxml 4.0 on windows 2000.

There is also a winsock based solution. You need to download and install w3 sockets from http://www.dimac.net. A sample code is given below.

Set obj_sock=Server.CreateObject("Socket.TCP")
obj_sock.Host="www.yoursite.com:80"
str_request="POST /actionpage.asp HTTP/1.1" & vbcrlf
str_request=str_request & "Accept */*" & vbcrlf
str_request=str_request & "field1=value1&field2=value2&field3=value3" & vbcrlf
str_request=str_request & vbcrlf
obj_sock.Open()
obj_sock.SendLine str_request
obj_sock.WaitForDisConnect()
Response.Write "<pre>" & Server.HTMLEncode(obj_sock.buffer) & "</pre>"
obj_sock.Close()

obj_sock.buffer will give the output from actionpage.asp. More help is included with the component.

This was working correctly on windows NT (IIS 4.0) also.
 
Old October 29th, 2004, 05:39 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

takabyte

I am still intrigued at why you would want to over engineer passing values from one page to another. I'm sure you have a good reason however I can think of to many.

Wind is your friend
Matt
 
Old October 29th, 2004, 09:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes Anubav, Madhu is right. This wouldn't result in any sort of error, when the right versions MSXML parsers are in place.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 29th, 2004, 11:41 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Dear Matt,

Submitting values in this way is needed in accessing some web services. For e.g. the SMS service offered by www.sms-wap.com. Here we need to pass some values to a remote web page. We cannot submit a form to that page as the submitted values will go as the body of the request. We need to send some header request as well as some body request. I was using w3 sockets in that situation.

The XML based method is a good one to submit data without refreshing the page. This may be required in some cases.
 
Old November 1st, 2004, 12:49 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

madhukp

Thanking you, some interestingly useful information.

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
form submitting cro_crx Pro PHP 5 January 25th, 2005 12:19 PM
Form Submitting cro_crx Beginning PHP 3 January 17th, 2005 01:30 PM
Submitting a form YuliaKupina Classic ASP Basics 3 June 24th, 2004 01:52 AM
Using XMLHTTP to POST form data channer Classic ASP XML 8 January 6th, 2004 05:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.