Solved

Introducing a Paypal form in a C# document

Posted on 2009-04-14
5
647 Views
Last Modified: 2012-05-06
My code is attached.

Towards the bottom of the page, there's a series of input fields that are being sent to paypal (search for Aggregated items). I'm attempting to put the field that's carrying the total amount in the form and I get this message:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="invoice.aspx.cs" Inherits="Invoice" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Quality Assurance Invoice</title>
    <LINK href="style1.css" type="text/css" rel="stylesheet">
</head>
<body>
    <form id="form1" runat="server">
    <div style="font-family:Verdana; text-align:center">
        <asp:Button ID="btnDone" runat="server" Text="Done" OnClick="btnDone_Click" /><br />
        <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label></div>
    <div style="text-align:right; font-family:Verdana">
        <img src="images/qmslogo.jpg" alt="qmslogo" />
        <font size="+2"><b>Quality Assurance INVOICE</b></font><br />
        INVOICE #:
        <asp:Label ID="lblInvoiceNum" runat="server"></asp:Label><br />
        Date: <asp:Label ID="lblDateCompleted" runat="server"></asp:Label><br />
        Tax ID: <asp:Label ID="lblTaxId" runat="server"></asp:Label><br />
        <asp:Label ID="lblEmailTo" runat="server"></asp:Label>
        &nbsp;&nbsp;</div>
    <div style="text-align:left; font-family:Verdana">
        <span style="font-size: 11pt">
        <b>Bill To:</b><br />
        </span>
        <div style="padding-left:0.5in; padding-top:5px">
            <asp:Label ID="lblCompanyName" runat="server"></asp:Label><br />
            <asp:Label ID="lblCompanyContact" runat="server"></asp:Label><br />
            <asp:Label ID="lblCompanyAddr" runat="server"></asp:Label><span style="font-size: 11pt">
                <br />
            </span>
        <br />
    <table style="font-family:Verdana" width="80%" align="center">
        <tr>
            <td width="33%" align="center">
                QC CONTROL NO.<br />
                <asp:Label ID="lblQmsCtrlNum" runat="server" Font-Bold="True"></asp:Label></td>
            <td width="33%" align="center">
                Period Funded<br />
                <asp:Label ID="lblPeriodFunded" runat="server" Font-Bold="True"></asp:Label></td>
            <td width="34%" align="center">
                Terms<br />
                <i><b>Due on receipt</b></i>
            </td>
        </tr>
    </table>
            <br />
        </div>
    </div>
    <div style="font-family:Verdana; text-align:center">
    <asp:Label ID="Label4" runat="server" Text="Quality Control Reviews" Font-Names="Verdana" Font-Bold="True" Font-Size="Large"></asp:Label>
        <asp:GridView ID="gvBilling" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="90%" OnRowDataBound="gvBilling_RowDataBound" Font-Size="Small">
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <Columns>
                <asp:TemplateField HeaderText="Count">
                    <ItemTemplate>
                        <asp:Label ID="lblRowNum" runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="loan_number" HeaderText="Case #" />
                <asp:BoundField DataField="first_name" HeaderText="First Name" />
                <asp:BoundField DataField="last_name" HeaderText="Last Name" /><asp:BoundField DataField="cost" HeaderText="Cost" DataFormatString="{0:c}" HtmlEncode="False" >
                    <ItemStyle HorizontalAlign="Right" />
                    <HeaderStyle HorizontalAlign="Right" />
                </asp:BoundField>
            </Columns>
            <RowStyle BackColor="White" ForeColor="#003399" />
            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
        </asp:GridView>
        <div align=right>
        <asp:Label
            ID="lblTotalWord1" runat="server" Text="Total" Font-Bold="True" Font-Size="Large"></asp:Label>&nbsp;&nbsp;
            &nbsp;<asp:Label ID="lblTotalDue" runat="server" Text="$0.00"></asp:Label>&nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
                    </div>
        &nbsp; &nbsp;&nbsp;
        <asp:Label ID="Label5" runat="server" Text="Early Payment Default Audit" Font-Bold="True" Font-Size="Large"></asp:Label><br />
        <asp:GridView ID="gvEPD" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="90%" OnRowDataBound="gvBilling_RowDataBound" Font-Size="Small">
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <Columns>
                <asp:TemplateField HeaderText="Count">
                    <ItemTemplate>
                        <asp:Label ID="lblRowNum" runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="loan_number" HeaderText="Case #" />
                <asp:BoundField DataField="first_name" HeaderText="First Name" />
                <asp:BoundField DataField="last_name" HeaderText="Last Name" />
                <asp:BoundField DataField="Early_Payment_Default" HeaderText="EPD" SortExpression="Early_Payment_Default" />
                <asp:BoundField DataField="cost" HeaderText="Cost" DataFormatString="{0:c}" HtmlEncode="False" >
                    <ItemStyle HorizontalAlign="Right" />
                    <HeaderStyle HorizontalAlign="Right" />
                </asp:BoundField>
            </Columns>
            <RowStyle BackColor="White" ForeColor="#003399" />
            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
        </asp:GridView>
        <div align=right><asp:Label ID="Label1"
            runat="server" Text="Total" Font-Bold="True" Font-Size="Large"></asp:Label>
            &nbsp; &nbsp;<asp:Label ID="lblTotal2" runat="server" Text="$0.00"></asp:Label>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        </div>
        &nbsp; &nbsp;&nbsp;<asp:Label ID="Label6" runat="server" Text="Denial/Withdrawn" Font-Bold="True" Font-Size="Large"></asp:Label><br />
        <asp:GridView ID="gvDenied" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="90%" OnRowDataBound="gvBilling_RowDataBound" Font-Size="Small">
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <Columns>
                <asp:TemplateField HeaderText="Count">
                    <ItemTemplate>
                        <asp:Label ID="lblRowNum" runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="loan_number" HeaderText="Case #" />
                <asp:BoundField DataField="first_name" HeaderText="First Name" />
                <asp:BoundField DataField="last_name" HeaderText="Last Name" />
                <asp:BoundField DataField="loan_denied" HeaderText="Denied" HtmlEncode="False" /><asp:BoundField DataField="cost" HeaderText="Cost" DataFormatString="{0:c}" HtmlEncode="False" >
                    <ItemStyle HorizontalAlign="Right" />
                    <HeaderStyle HorizontalAlign="Right" />
                </asp:BoundField>
            </Columns>
            <RowStyle BackColor="White" ForeColor="#003399" />
            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
        </asp:GridView>
        <div align=right>
 
<!- here's your total ->
 
        <asp:Label ID="Label2"
            runat="server" Text="Total" Font-Bold="True" Font-Size="Large"></asp:Label>
            &nbsp; &nbsp;<asp:Label ID="lblTotal3" runat="server" Text="$0.00"></asp:Label>
            &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        </div>
       
        <asp:Label ID="Label7" runat="server" Text="Field Review Appraisal" Font-Bold="True" Font-Size="Large"></asp:Label><br />
        <asp:GridView ID="gvFRA" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="90%" OnRowDataBound="gvBilling_RowDataBound" Font-Size="Small">
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <Columns>
                <asp:TemplateField HeaderText="Count">
                    <ItemTemplate>
                        <asp:Label ID="lblRowNum" runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="loan_number" HeaderText="Case #" />
                <asp:BoundField DataField="first_name" HeaderText="First Name" />
                <asp:BoundField DataField="last_name" HeaderText="Last Name" />
                <asp:BoundField DataField="Field_Review" HeaderText="FRA" SortExpression="FRA" />
                <asp:BoundField DataField="cost" HeaderText="Cost" DataFormatString="{0:c}" HtmlEncode="False" >                
                    <ItemStyle HorizontalAlign="Right" />
                    <HeaderStyle HorizontalAlign="Right" />
                </asp:BoundField>
            </Columns>
            <RowStyle BackColor="White" ForeColor="#003399" />
            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
        </asp:GridView>
        
        <div align=right><asp:Label
            ID="Label3" runat="server" Text="Total" Font-Bold="True" Font-Size="Large"></asp:Label>
            &nbsp;&nbsp;
        <asp:Label ID="lblTotal4" runat="server" Text="$0.00"></asp:Label>&nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp;&nbsp;
        </div>
        &nbsp; &nbsp;&nbsp;<table id="FRATotals" width="90%" align="center" cellpadding="5">
            <tr>
                <td width="10%">&nbsp;</td>
                <td width="10%">&nbsp;</td>
                <td width="10%">&nbsp;</td>
                <td width="10%">&nbsp;</td>
                <td width="*%" align="right">
                    LATE CHARGES</td>
                <td width="20%" align="right">
                    <asp:Label ID="lblOtrCharges" runat="server">$0.00</asp:Label></td>
            </tr>
            <tr>
                <td width="10%">&nbsp;</td>
                <td width="10%">&nbsp;</td>
                <td width="10%">&nbsp;</td>
                <td width="10%">&nbsp;</td>
                <td width="*%" align="right">
                    OTHER CHARGES</td>
                <td width="20%" align="right">
                    <asp:Label ID="lblOtherCharges" runat="server">$0.00</asp:Label>
                </td>
            </tr>
            
            <tr>
                <td colspan="5" align="right">SHREDDING/SHIPPING & HANDLING</td>
                <td align="right">
                    <asp:Label ID="lblShipping" runat="server" Text="$0.00"></asp:Label></td>
            </tr>
            <tr>
                <td colspan="5" align="right"><b>NET TOTAL</b></td>
                <td align="right">
 <!- here's my Paypal form ->
 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
 <input type="hidden" name="business" value="bruce@brucegust.com">
    <input type="hidden" name="item_name" value="Aggregated items">
    <input type="hidden" name="amount" value="<asp:Label ID="lblGrandTotal" runat="server" Text="$0.00" Font-Bold="True" Font-Size="Large"></asp:Label>">
 <input type="hidden" name="return" value="http://www.brucegust.com/ChapelThunder/Customer/Verify.asp">
        
 <input type="hidden" name="currency_code" value="USD">
 <input type="image" src="Images/TransactionComplete.jpg" border="0" name="submit"></form>
                   </td>
            </tr>
        </table>
    </div>
    <br /><br />
    <div style="font-family:Verdana; text-align:left">
        If you have any questions concerning this invoice, please contact Thomas F. Duncan at 615-591-2528 ext 22, 
        or email tduncan@qcmortgage.com. Make all checks payable to:<br />
        <br />
        <b>Quality Mortgage Services</b>.<br />
        1111 Lakeview Drive, Franklin TN 37067<br /><br />
        <font size="-1">Balances over 30 days will accrue a charge of 2% per month.</font>
    </div>
    </form>
</body>
</html>
Error:
 
Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlInputHidden' does not contain a definition for 'Text'
Source Error:
Line 605:        //Double val4 = Convert.ToDouble(lblTotal4.Text);
Line 606:        Double valTotal = Convert.ToDouble(total) + Convert.ToDouble(otherCharges) + Convert.ToDouble(shipping) + Convert.ToDouble(otrCharges);
Line 607:        lblGrandTotal.Text = Convert.ToString(String.Format("{0:c}", valTotal));
Line 608:    }
Line 609:
 

Open in new window

0
Comment
Question by:brucegust
[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
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24144324
Hi brucegust,
I've noticed that you put the label control inside hidden's field? Try strip out the label control from the hidden field and set it as server control
eg:

aspx
============
   <input type="hidden" name="amount" value="<asp:Label ID="lblGrandTotal" runat="server" Text="$0.00" Font-Bold="True" Font-Size="Large"></asp:Label>">

Should be
   <input type="hidden" name="amount" value="$0.00" id="amount" runat="server">

c#
======
    amount.Text = Convert.ToString(String.Format("{0:c}", valTotal));
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24144332
Some amendment:
Use "value" instead of "text" property for HtmlInputHidden control
eg:
amount.value = Convert.ToString(String.Format("{0:c}", valTotal));
0
 

Author Comment

by:brucegust
ID: 24181243
x_com...

I'm thinking we're on to something but the fact that I'm still very new to C#, I'm obviously missing something.

Where do I put "amount.Text = Convert.ToString(String.Format("{0:c}", valTotal));" There's another file called invoice.aspx.cs. Does it go there? Sorry for being so thick, but there it is.
0
 

Author Comment

by:brucegust
ID: 24181284
After some additional playing around, I tried this:

This is a portion of the code on the invoice.aspx.cs file that appeared to be calculating the grand total. I put your cs code in it thinking this would be cake and ice cream. On trying it, I got the following error:


Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlInputHidden' does not contain a definition for 'value'

Source Error:

 

Line 606:        Double valTotal = Convert.ToDouble(total) + Convert.ToDouble(otherCharges) + Convert.ToDouble(shipping) + Convert.ToDouble(otrCharges);
Line 607:        lblGrandTotal.Text = Convert.ToString(String.Format("{0:c}", valTotal));
Line 608:        amount.value = Convert.ToString(String.Format("{0:c}", valTotal));
Line 609:    }
Line 610:
 

Source File: c:\www\analyze\invoice.aspx.cs    Line: 608


What am I doing wrong?


private void calculateGrandTotal()
    {
        //this.total = this.otherCharges + this.subtotal + this.shipping;
        //lblGrandTotal.Text = total.ToString("c");
        //Double val1 = Convert.ToDouble(lblTotalDue.Text);
        //Double val2 = Convert.ToDouble(lblTotal2.Text);
        //Double val3 = Convert.ToDouble(lblTotal3.Text);
        //Double val4 = Convert.ToDouble(lblTotal4.Text);
        Double valTotal = Convert.ToDouble(total) + Convert.ToDouble(otherCharges) + Convert.ToDouble(shipping) + Convert.ToDouble(otrCharges);
        lblGrandTotal.Text = Convert.ToString(String.Format("{0:c}", valTotal));
        amount.value = Convert.ToString(String.Format("{0:c}", valTotal));
    }

Open in new window

0
 
LVL 29

Assisted Solution

by:David H.H.Lee
David H.H.Lee earned 500 total points
ID: 24191484
Hi brucegust,
Have you put a hidden object named "amount" as proposed previously in aspx page? Lastly, make sure the control is being declared in the c# code-behind - "invoice.aspx.designer.cs" file. Please clarify if you need any further assistance.
eg:
protected global::System.Web.UI.HtmlControls.HtmlInputHidden amount;

Note: I'm using VS.net 2008 for the testing.


0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

630 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