Solved

Issue with Creating a Form on the Fly

Posted on 2013-10-30
3
237 Views
Last Modified: 2013-11-30
Hi

Due to ASP.net now allowing a Form within an ASP:Form for the payment provider I am creating a form on the fly and using JQuery to trigger this

Everything is fine until the amount which is being problematic:

Dim Url As String = "https://MyPaymentProvider"
            Dim formId As String = "myForm1"

            Dim htmlForm As New StringBuilder()
            htmlForm.AppendLine("<html>")
            htmlForm.AppendLine([String].Format("<body onload='document.forms[""{0}""].submit()'>", formId))
            htmlForm.AppendLine([String].Format("<form id='{0}' method='POST' action='{1}'>", formId, Url))
            htmlForm.AppendLine("<input type='hidden' name='PSPID' value='MyCode'>")
            htmlForm.AppendLine([String].Format("<input type='hidden' name='ORDERID' value='{0}'>", orderid))
            htmlForm.AppendLine([Int32].Parse("<input type='hidden' name='AMOUNT' value='{0}'>", amount))
            htmlForm.AppendLine("<input type='hidden' name='CURRENCY' value='GBP'>")
            htmlForm.AppendLine("<input type='hidden' name='LANGUAGE' value='en_US'>")
            htmlForm.AppendLine("</form>")
            htmlForm.AppendLine("</body>")
            htmlForm.AppendLine("</html>")

            HttpContext.Current.Response.Clear()
            HttpContext.Current.Response.Write(htmlForm.ToString())
            HttpContext.Current.Response.[End]()

Open in new window


The issue I am having is with this line of code htmlForm.AppendLine([Int32].Parse("<input type='hidden' name='AMOUNT' value='{0}'>", amount)) and it keeps throwing the following error:
An undefined NumberStyles value is being used.
Parameter name: style

Amount is an int32 variable as the payment provider expects this as the decimal amount multiplied by 100

If anyone can help it would be most appreciated
0
Comment
Question by:TPLLimited
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39611969
The Int32.Parse method takes a string containing a number as its first parameter.

You should be doing:
htmlForm.AppendLine([String].Format("<input type='hidden' name='AMOUNT' value='{0}'>", [Int32].Parse(amount)))

Open in new window

0
 

Author Comment

by:TPLLimited
ID: 39612012
Hi

Thanks for the response

I did try that but the payment provider then refuses the payment due to it not being non numeric

Error on Payment provider website:

amount too long or not numeric: length 46 MAX:15
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39612485
If you out the contents of htmlForm to the screen instead of submitting to the provider, what does the input tag for Amount look like? Are there extra spaces in the value property? Is the amount a valid number?
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question