I am new to programming but attempting to learn. Im running visual studio 2010 with an asp.net webform project using C#. I am trying to implement paypals buy now buttons on one of the pages and the code that is generated is in form tags also. No matter which button it is, the first button on the page never works and there is a solid blue line underneath it. All the other buttons work fine. even if i remove it, the next button becomes the first on the page and then it too doesnt work....i am learning that since all the pages are forms and the code generated is also a form, i cannot have a form inside a form. Is this correct? Is there any way around this...all i really know is a lil HTML and a lil CSS, i am trying to learn JavaScript, C#, XML, CSS, ASP.NET, as well as Visual Studio itself. Any help would be greatly appreciated. If anyone wants to see what im talking about go to www.curbappealfordummies.net/Packages.aspx That is the site im working on and webmaster of...Thank you guys for your help.
Maybe you need to start with a tutorial designed to help you get enough of the basics under your belt so that you can make better sense out of the things you really want to do... check out the video at http://www.asp.net/general/videos/build-your-first-asp-net-application-with-asp-net-web-forms and there are lots of resources there too. It's not that hard if you are motivated to learn, which it sounds like you are.
This is a wide-reaching question, but one possible answer is to generate a second form which has the needed PayPal code in it.
This is a simplified example; usually there is logic needed to lead up to this point. For example, if the buttons need to be contained within the ASP.Net default form, there will need to be server and/or client code to connect them to this second form and to make sure that it contains the correct hidden values.
In Your WebForm
<form id="form1" runat="server">
<!-- Contents of your server form -->
</form>
<%=base.GetMarkupOutsideDefaultForm() %>
In Your CodeBehind
public string GetMarkupOutsideDefaultForm()
{
//
// Return the markup needed for a PayPal form,
// including javascript needed to automatically submit it.
// AppSettings can be any configuration object that contains
// the needed URL (or you can hardcode it)
StringBuilder sb = new StringBuilder();
sb.Append( "<form action=\"" + AppSettings.PayPalUrl + "\" method=\"post\" id=\"frmPayPal\" target=\"_blank\">" );
// add hidden PayPal fields
sb.Append( "</form>" );
sb.Append( "<script type=\"text/javascript\">document.forms[\"frmPayPal\"].submit();</script>" );
return sb.ToString();
}
If the logic is complex, the second block of code should really be contained in a helper class.
Hope this puts someone on the right path.
I know what you mean. Try adding an extra
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='paypal'></form>
At the top.
Example:
<form id="form1" runat="server">
<div>
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='paypal'>
</form>
</div>
<div>
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='paypal'>
<input type='hidden' name='add' value='1'>
<input type='hidden' name='cmd' value='_cart'>
<input type='hidden' name='business' value='<%# DataBinder.Eval(Container.DataItem, "business_email") %>'>
<input type='hidden' name='no_shipping' value='0'>
<input type='button' name='submit' value='Add To Cart' title='Add to Cart Button'>
</form>
</div>
</form>
Simple, but it works.
Or, if you don't like that idea, try this post: