Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 July 29th, 2005, 05:41 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET Form Action not working

I'm trying to pass form parameters to worldpay for an e-commerce site and the action does not work, I suspect because of runat="server".

The page does not move to the URL in the form action, any ideas?

Here is my form tag:

 <form action="https://select.worldpay.com/wcc/purchase" method="post" id="Form1" runat="server" onSubmit="return validateForm(this)">

 
Old July 29th, 2005, 05:53 AM
Authorized User
 
Join Date: Nov 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

in ASP.NET you can't change action of runat=server form, for that you can use server.transfer.

Avanish Pandey
Set your heart upon your work, but never on its reward
 
Old July 29th, 2005, 06:01 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tried that but no joy, according to another website - "But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site."

As you can see my url is an external site - action="https://select.worldpay.com/wcc/purchase"

 
Old July 29th, 2005, 06:24 AM
Authorized User
 
Join Date: Nov 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

ok, then you can ues WebClient and can use UploadValues, UploadData methods of that.

Avanish Pandey
Set your heart upon your work, but never on its reward
 
Old July 29th, 2005, 07:03 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Taken a look at WebClient on the MSDN site and looks confusing on how to pass form values, any more help would be appreciated

http://msdn.microsoft.com/library/de...classtopic.asp
Richard

 
Old July 29th, 2005, 07:11 AM
Authorized User
 
Join Date: Nov 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

Dim myWebClient As New WebClient()
        Dim myNameValueCollection As New NameValueCollection()
        myNameValueCollection.Add("Value1", "value for value1")
        myNameValueCollection.Add("Value2", "value for value2"))
        Dim responseArray2 As Byte() = myWebClient.UploadValues("http://yoururl.com/page.aspx", "POST", myNameValueCollection)



Avanish Pandey
Set your heart upon your work, but never on its reward
 
Old July 29th, 2005, 08:53 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tried using the code above but the page does not redirect to the url

Sub PostData()

Dim myWebClient As New WebClient()
        Dim myNameValueCollection As New NameValueCollection()
        myNameValueCollection.Add("Value1", cleanSQLCharacters(Request.Form("FirstName")))
        myNameValueCollection.Add("Value2", cleanSQLCharacters(Request.Form("LastName")))
        myNameValueCollection.Add("Value3", cleanSQLCharacters(Request.Form("Address1")))
        myNameValueCollection.Add("Value4", cleanSQLCharacters(Request.Form("Address2")))
        myNameValueCollection.Add("Value5", cleanSQLCharacters(Request.Form("City")))
        myNameValueCollection.Add("Value6", cleanSQLCharacters(Request.Form("County")))
        myNameValueCollection.Add("Value7", cleanSQLCharacters(Request.Form("PostCode")))
        myNameValueCollection.Add("Value8", cleanSQLCharacters(Request.Form("ddlCategory")))
        Dim responseArray2 As Byte() = myWebClient.UploadValues("https://select.worldpay.com/wcc/purchase", "POST", myNameValueCollection)

End Sub

 
Old July 30th, 2005, 02:09 AM
Authorized User
 
Join Date: Nov 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

Hi,

Yes problem is that it will post data but not redirect you to that page... After you've validated the user input server-side you can call server-side function which will response.write to your page some HTML + JS code and this will send the form
Consider the following ASP.NET code:
----------------------------------------------

Response.Write("&lt;form name='YourForm' action='http://your_url_here' method='POST' &gt;")

Response.Write("&lt;input type='hidden' name='Var1' value='5' &gt;")
Response.Write("&lt;input type='hidden' name='Var2' value='test' &gt;")

Response.Write("&lt;form&gt;")

Response.Write("&lt;script&gt;")
Response.Write("document.YourForm.submit();")
Response.Write("&lt;/script&gt;")

Avanish Pandey
Set your heart upon your work, but never on its reward
 
Old July 30th, 2005, 08:10 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Richard,

An initial thought was that you could just remove 'runat="server"' from you form tag. Then it won't get handled by ASP.NET. However, I then reallized that you might be filling in some values in the form and would want ASP.NET control over those controls.

There's no reason you can't emit a simple piece of client side code that changes the form action value after the page is loaded. This way you can deal with the form as a regular ASP.NET web form and have server side access to set values to the controls, but then change the form's action target after the form has been loaded at the client. Then when it's submitted it will post to the worldpay site.

-Peter
 
Old July 30th, 2005, 09:32 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peter,

I will give it a try when I get back from a golfing holiday in Dublin next Thursday!

Richard






Similar Threads
Thread Thread Starter Forum Replies Last Post
access C#.Net page as action of calssic ASP page mansharma_s ASP.NET 1.x and 2.0 Application Design 6 January 7th, 2008 10:58 AM
form action attribute austinf HTML Code Clinic 2 August 2nd, 2006 08:30 AM
Two action in a form johnjohn Classic ASP Components 1 November 16th, 2004 05:45 PM





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