Solved

Issue with Creating a Form on the Fly

Posted on 2013-10-30
3
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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.…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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