I know I know, why would I want to submit the form from server-side code, if the only way to get to the server-side code was BY submitting the form. But that's just it, when the code-behind page_load event fires it doesn't really "submit" the form as I would like it submitted.
Here's my problem, I made a shopping cart for a website, and to get the information securely paid for I need to send a form to paypal using method="post" and action="big long url". In asp.net I can't have multiple forms with runat="server" on the same web page, so what I did was create a new page with the only form being the send-to-paypal form, and the page_load event handler in the codebehind populates the form tag with the correct transaction information (item names, prices, shipping, etc). Currently I have to have it create a button here too with type="submit". You have to click the button before the transaction is sent to paypal. Is there a way to make the Page_Load event fire the form's submit event so I don't have to require a button click?
Here's the html part of the new page with the form: - <div id="SendPaypalInfo" runat="server">
-
<FORM action="https://www.paypal.com/cgi-bin/webscr" method="post" runat="server"></FORM>
-
</div>
-
and then here's the current Page_Load codebehind: - Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
If Not Page.IsPostBack Then
-
Dim TextToSend As String = ""
-
Dim a As Integer
-
-
RetrieveSessionVariables()
-
-
TextToSend = "<form name=""PaypalSubmitForm"" action=""https://www.paypal.com/cgi-bin/webscr"" method=""post"" runat=""server"">"
-
TextToSend = TextToSend & "<input type=""hidden"" name=""cmd"" value=""_cart"">"
-
TextToSend = TextToSend & "<input type=""hidden"" name=""business"" value=""EDITED"">"
-
TextToSend = TextToSend & "<input type=""hidden"" name=""upload"" value=""1"">"
-
TextToSend = TextToSend & "<input type=""submit"" value=""Click Here""></form>"
-
-
-
Me.SendPaypalInfo.InnerHtml = TextToSend
-
-
End If
-
End Sub
Can i submit the form in that very same page_load event? i don't want them to have to click that button :(
May 2 '06
16 19043
Yes. I am getting the value on alert. Only the submit part is not working. I believe it is because I have runat="server" in the form tag. But if I don't mention this, AJAX method won't be executed. This is like a deadlock for me now!!
Yes. I am getting the value on alert. Only the submit part is not working. I believe it is because I have runat="server" in the form tag. But if I don't mention this, AJAX method won't be executed. This is like a deadlock for me now!!
How did you specify that the Javascript function should be called on the form?
Instead of having runat server call the javascript function onSubmit() of the form and see what happens.
<form id="frmLogin" name="frmLogin" onsubmit="submi tf();">
I tried this. But AJAX method didn't get executed. Because I need to have runat="server". If I mention this (as below), the form doesn't get submitted.
<form id="frmLogin" name="frmLogin" runat="server" onsubmit="submi tf();">
<form id="frmLogin" name="frmLogin" onsubmit="submi tf();">
I tried this. But AJAX method didn't get executed. Because I need to have runat="server". If I mention this (as below), the form doesn't get submitted.
<form id="frmLogin" name="frmLogin" runat="server" onsubmit="submi tf();">
That's strange. You certainly don't need the runat="server" control in order for you to be able to call an AJAX function as illustrated in the example here.
Here, in this example, everything is done in client side javascript itself. Even the methods are defined in JS. But in my case, I have a public method which will be in server side when I execute the form and it is only available to the form when it runs on server.
Here, in this example, everything is done in client side javascript itself. Even the methods are defined in JS. But in my case, I have a public method which will be in server side when I execute the form and it is only available to the form when it runs on server.
How's this workaround:
Submit the form before checking the value of the AJAX request then perform the check on the serverside code (you no longer need AJAX for that). An if else on the server side would bring the initial page or proceed with the processing. Of course this means that the page has to be submited ...
I am not submitting the form to the same page. Once the AJAX method returns true value, the form gets submitted to another server mentioned in action attribute of the form tag.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tony Hedge |
last post by:
Hello,
I hope some one can answer this for me.
I am using .NET version 1.0 on Windows 2000Pro and I am
getting an error when doing a form submit from an HTML
control. Please look at the following brief code example:
I have two aspx file WebForm1.aspx and WebForm2.aspx.
WebForm1 has the following elements:
|
by: Scott |
last post by:
How can I tell a form to submit itself in the code-behind
in vs.net?
In other words, in javascript I can do blah.submit() - how
do I do this in vs.net code-behind?
|
by: Niks |
last post by:
Hi,
I am creating a simple .aspx page to add some fields with validation.
I have used different .NET validations like REquiredFieldValidator,
RegularExpressionValidator and showed the summary in the bulleted list
on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons.
One for Submit, Reset and Exit.
If submit is pressed page should be validated and submit (insert into
|
by: Arun K |
last post by:
Hi,
I am creating a simple .aspx page to add some fields with validation.
I have used different .NET validations like REquiredFieldValidator,
RegularExpressionValidator and showed the summary in the bulleted list
on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons. One
for Submit, Reset and Exit.
If submit is pressed page should be validated and submit (insert into
|
by: Perry van Kuppeveld |
last post by:
Hi,
I have a problem with formatting a table including text fields wich can
contain up to 255 chars.
I need a table with 3 columns:
- First column 50 % over the with a rowspan of the total number of rows.
- Second column 25 %, no rowspan
- Third column 25 %, no rowspan
| |
by: milkyway |
last post by:
Hello there,
I have the following code (written in Javascript) for posting of a form
on the client side:
....
var f2 = document.forms;
f2.method = "post";
f2.submit();
|
by: PJ6 |
last post by:
When I have client-side script like this -
document.forms.submit('test')
how do I access, from server-side code, the value I put in the submit
method?
Also, is it possible to get the control's containing form name so I can
emite script like this -
|
by: Anthony |
last post by:
I have a form on a web page that requires to click on a button to
submit the information. I have two questions about changing this form:
1. Is there a way that I can change the script so that the form can be
submitted by hitting the enter key?
2. Is there a way that I can have the Username and Password boxes
cleard after the form is submitted?
You probably don't need the code for the form as it is pretty basic but
here it is just in...
|
by: The Natural Philosopher |
last post by:
I am coding up a bit of javascript stuff, and have managed to stumble my
way through most of what I want..
But this one has got me stumped.
I call submit() and get a javascript error 'Submit not defined' in Firefox..
My very expensive javascript Bible assures me its built in ..so where oh
where have I FSCKED up?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |