Solved

asp.listview and paypal problem

Posted on 2010-11-09
11
712 Views
Last Modified: 2012-08-13
I am trying to use the asp:listview to add products to a page.
I have managed to get them all the page.  
But when  I add the <form...etc for the paypal button, the first element in the list seems to render as its own list.

I view source and the source only has one <ul> body, so I am bit stuck as to what is happening,

I ahve tried changing the <ul><li> to tables instead but I still get the same problem.

Please help
<asp:listview id="pics" runat="server"
			ondatabinding="pics_DataBinding" onitemdatabound="pics_ItemDataBound" >
			<layouttemplate>
				<ul class="picList">
					<placeholder id="itemPlaceholder" runat="server" />
				</ul>
			</layouttemplate>
		
			<itemtemplate>
				<li>
					<img src="Photos/<%#Eval("PhotoName")%>.jpg" alt=""/>
						<form name="ppform" id="ppform" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
							<input type="hidden" name="add" value="<%#Eval("PhotoName")%>"></input>
							<input type="hidden" name="cmd" value="_cart"></input>
							<input type="hidden" name="business" value="inf0@vnayer.com"></input>
							<input type="hidden" name="item_name" value="VNayer Photography"></input>
							<input type="hidden" name="item_number" value="<%#Eval("PhotoName")%>"></input>
							<input type="hidden" name="no_shipping" value="0"></input>
							<input type="hidden" name="no_note" value="1"></input>
							<input type="hidden" name="on0" value=""></input>
							<input type="hidden" name="return" value="http://www.vnayerphotography.com/default.aspx"></input>
							<input type="hidden" name="currency_code" value="GBP"></input>
							<input type="hidden" name="lc" value="UK"></input>
							<input type="hidden" name="bn" value="PP-ShopCartBF"></input>
							<input type="hidden" name="shipping" value="0.00"></input>
							<input type="hidden" name="flatRateShipping" value="true"></input>
							<input type="hidden" name="flatShippingCost" value="0.00"></input>
							<input type="hidden" name="localPickup" value="false"></input>
							<select name="amount" id="sizes">
								<option value="35">10x8 Print -  £35.00</option>
								<option value="12.50">7x5 Print -  £12.50</option>
								<option value="5.50">6x4 Print -  £5.50</option>
							</select>
							<br />
							<input type="image" src="../images/shoppingcart.gif" name="submit" style="padding:0px;margin-bottom:-2px;" alt="PayPal!"></input>
						</form>
					</li>
			</itemtemplate>

			<emptydatatemplate>
				<div>
					Sorry - no photos found
				</div>
			</emptydatatemplate>
		</asp:listview>

Open in new window

vnayersnip.JPG
0
Comment
Question by:vpatel2708
[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
  • 6
  • 5
11 Comments
 
LVL 18

Expert Comment

by:Richard Lee
ID: 34095161
Having several form tags in a ASP.NET Webforms page seems like a big no no. What I have done in the past is construct on the server a PayPal Url and redirect to paypal. This of course would eliminate your need for forms and saving the data in the page. Reduced page size, less security risk as you are only exposing a unique key for each product.

DaTribe
0
 
LVL 18

Assisted Solution

by:Richard Lee
Richard Lee earned 500 total points
ID: 34099832
I thought I would supply a code sample to illustrate. The Navigator class simple builds a Url and allow redirect to that Url.

DaTribe
private Navigator BuildPayPalUrl()
{
	Navigator navigator = new Navigator { Page = "https://www.paypal.com/cgi-bin/webscr" };

	navigator["cmd"] = "_xclick";
	navigator["business"] = "Your Business Code";
	navigator["lc"] = "GB";
	navigator["item_name"] = _product.Name;
	navigator["item_number"] = _product.Code;
	navigator["amount"] = _product.Cost.ToString("#0.00");
	navigator["currency_code"] = _currency.Code;
	navigator["no_note"] = "1";
	navigator["no_shipping"] = "1";
	navigator["rm"] = "1";
	navigator["return"] = "Your return url";
	navigator["cancel_return"] = "Your cancel url";
	navigator["notify_url"] = "Your IPN url";
	navigator["custom"] = "Unique ID such as sale ID or whatever you like";

	return navigator;
}

Open in new window

0
 
LVL 1

Author Comment

by:vpatel2708
ID: 34099925
Thanks DaTribe...

Would you just put this onto the click event of your add to cart button then?

0
Independent Software Vendors: 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!

 
LVL 18

Expert Comment

by:Richard Lee
ID: 34099955
Probably just the product code or something that would identify what product they chose. Depending on how the site allows users to list prices in various currencies that might have to be sent also.

DaTribe
0
 
LVL 1

Author Comment

by:vpatel2708
ID: 34100256
Still a little lost in the execution of the thing as a whole.

So let me start by what I am thinking.

In the markup, <ItemTemplate> I would have my image as it is, then a dropdownlist to show the options that are available to buy and an add to cart button, this button when clicked would need to tell serverside the product chosen and the option in the dropdownlist chosen.

On sever side I can then construct the URL and redirect to that url??  is that right?

Also would be great if you could post a small sample of what the Navigator class looks like...cheers
0
 
LVL 18

Expert Comment

by:Richard Lee
ID: 34100341
OK await a sample code snippet. Since I left all my resources at home I would have to reconstruct.

DaTribe
0
 
LVL 1

Author Comment

by:vpatel2708
ID: 34100374
Thank you for your help, its really appreciated
0
 
LVL 18

Accepted Solution

by:
Richard Lee earned 500 total points
ID: 34100919
Okay I have produced a sample however the process/flow is as follows:

Show Products --> Add to Basket --> Checkout --> Collect Payment via PayPal --> (Paypal communicate via IPN) --> Return Url --> (PayPal communicate via IPN)

Hopefully that didn't confuse you. I have communicate by IPN many times because depending on what is happening with the payment PayPal will always communicate in the background to let you know.

http://www.avantprime.com/experts-exchange/paypal-url-payment.zip

BTW this was a quick job so don't judge on the inline styles, lack of layers or separation, etc, etc :).

DaTribe
0
 
LVL 1

Author Comment

by:vpatel2708
ID: 34118459
Sorry for the delayed respose.

Thank you so much for the sample project, I didn't use your exact example, but your help definetly pointed me in the right direction and now I have my own shopping cart.

;-}
0
 
LVL 1

Author Closing Comment

by:vpatel2708
ID: 34118464
Very grateful for the trouble you went through to provide me a sample solution
0
 
LVL 18

Expert Comment

by:Richard Lee
ID: 34118873
Always glad to help!
0

Featured Post

Independent Software Vendors: 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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

729 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