?
Solved

Google Checkout buttons in ASPX Gridview

Posted on 2008-11-05
5
Medium Priority
?
1,789 Views
Last Modified: 2008-11-17
Hi

I have a web page which has a dynamically built gridview with items for sale and their description etc on each row. At the end i want to use a google checkout button to enable users to purchase the items. However i seem to be running into diffuclties with the generated code google creates for the button and my own code. I have attached code below which shows the datagird view in the asp page with the google button as it is now. (I have changed the merchantID). on the page this is displayed i get two results (two lines) if i click the first line button i get an error message... Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

when i click the second line item button it works fine...

whats going on - can you help...
ps. i have enabled event validation on my page.

<asp:GridView ID="dvTests" runat="server" AutoGenerateColumns="False" Width="560px">
                     <Columns>
                         <asp:TemplateField HeaderText="Test Name">
                             <ItemTemplate>
                                 <asp:Label ID="lblQuizName" runat="server" Text='<%# Eval("QuizName") %>'></asp:Label>
                             </ItemTemplate>
                         </asp:TemplateField>
                         <asp:TemplateField HeaderText="Type">
                             <ItemTemplate>
                                 <asp:Label ID="lblType" runat="server" Text='<%# Eval("Category") %>'></asp:Label>
                             </ItemTemplate>
                         </asp:TemplateField>
                         <asp:TemplateField HeaderText="Expiry">
                             <ItemTemplate>
                                  <span id=Expiry runat="server">
                                  <asp:Label ID="lblDate" runat="server" Text='<%# Eval("ExpirationDate", "{0:dd/MM/yyyy}") %>'></asp:Label>
                            </span>
                            </ItemTemplate>
                         </asp:TemplateField>
                         <asp:TemplateField HeaderText="Path" Visible="False">
                             <ItemTemplate>
                                  <asp:Label ID="lblPath" runat="server" Text='<%# Eval("FilePath") %>'></asp:Label>
                             </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField >
                   <ItemTemplate> 
            <form action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/448140563247512" id='<%# Eval("QuizName") %>' method="post" name='<%# Eval("QuizName") %>'>
                <input name="item_name_1" type="hidden" value='<%# Eval("QuizName") %>'/>
                <input name="item_description_1" type="hidden" value='<%# Eval("QuizName") %>'/>
                <input name="item_quantity_1" type="hidden" value="1"/>
                <input name="item_price_1" type="hidden" value='<%# Eval("Price") %>'/>
                <input name="item_currency_1" type="hidden" value="GBP"/>
                <input name="_charset_" type="hidden" value="utf-8"/>
                <input name='<%# Eval("QuizName") %>' alt="" src="https://checkout.google.com/buttons/buy.gif?merchant_id=448140563247512&amp;w=121&amp;h=44&amp;style=white&amp;variant=text&amp;loc=en_UK" type="image"/>
             </form>
                 </ItemTemplate> 
                  </asp:TemplateField>
                 </Columns>
                 </asp:GridView>

Open in new window

0
Comment
Question by:kingkev83
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22892787
no this is not correct way .. you need to put only button in gridview ... and need to handle button click event .... and on that event pass all the information

this would be like that
<asp:imagebutton id="btnSubmitPaypal" runat="server" imageurl="/images/google.gif" alternatetext="Purchase Using google checkout" postbackurl="https://checkout.google.com/cws/v2/Merchant/[your merchant number]/checkoutForm" />

refer this artical for details
http://dotnetdiscussion.net/2008/02/27/aspnet-how-to-integrate-both-google-checkout-and-paypal-in-3-steps/
0
 

Author Comment

by:kingkev83
ID: 22893381
How do I pass the information for each button click - each row will have different information.. I have tried this web site but im not sure where to call the  createcheckoutTag function and where i need to return to.. can you provide some code to help me along with this
 
0
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22893730
see on click of that button you will get selected row  event in grid event ... use that event ... and get the value from selected cell .. thats it
0
 

Author Comment

by:kingkev83
ID: 22893885
ON Click of that button gives me a button click event not a grid event.
Is there any way of doing this in javascript?  what I have running at the momnent is:

javascript: function Navigate(Location)
{
alert("You are now entering a secure site for payment")
javascript:window.open(Location);
}

ASP:
   <asp:TemplateField >
                   <ItemTemplate>
                          <asp:ImageButton OnClientClick="Navigate('https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/448140563247566')" ImageUrl="https://checkout.google.com/buttons/buy.gif?merchant_id=448140563247566&w=121&h=44&style=white&variant=text&loc=en_US" ID="Button" runat="server" />          
                  </ItemTemplate>
                  </asp:TemplateField>
I need to be able to pass the input parameters as well as the URL into the javascript to send the user to the right page - currently i get a whoops page with google
0
 

Accepted Solution

by:
kingkev83 earned 0 total points
ID: 22938079
I have managed to make a work around, I have used the google checkout which uses a javabased checkout system. It done the trick..
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 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