Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Issue with Creating a Form on the Fly

Posted on 2013-10-30
3
Medium Priority
?
253 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 27

Accepted Solution

by:
Shaun Kline earned 1500 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 27

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Loops Section Overview

610 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