Solved

Issue with Creating a Form on the Fly

Posted on 2013-10-30
3
227 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now