.NET Questions (CLOSED)Questions and Answers on any aspect of .NET. Now closed. |
||
|
This discussion group is now closed.
Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day. The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too. |
This is something I've struggled with on these groups before, and I'm still having problems with the uber-form that "owns" the entire ASP.Net page.
Specifically... Client has an ASP.Net site, and the content management architecture requires that the entire body of the page be contained in the ASP.Net form: <form runat="server"> They have one page that needs to have a PayPal submission form. This is the little HTML snippet PayPal sends that has a small form with some hidden fields and a "Donate" button that posts the form directly to PayPal's site. As near as I can tell, I'm screwed. When the form is put on the page, the action gets overridden by the main ASP form, and whenever you click the button, it doesn't post to PayPal, it just reloads the current page. I've had this problem before -- I had a single textbox that *had* to submit with GET. In this case, I posted the form, then did a Response.Redirect on the server to send it to the correct URL with the right querystring. It's a little goofy, but it works. This is more complicated -- the form's method is POST, and there's all sorts of hidden form fields. To send this from the server would be a pain (though it could be done, I guess). If PayPal ever sends new HTML, I'd have to recode the thing. I can't be the first person to have this problem. Any solutions?
Do a quick check on the HTML that is generated. I'm guessing that you'll have nested form tags, which doesn't work (at least I've never seen it work).
MTan Thursday, November 30, 2006
How about closing the form tag and then opening a form tag? This is assuming that you are using the one form in your Master Page... I imagine VS will whine about it though.
C Thursday, November 30, 2006
I'd check out if PayPal .Net API fits app design and, if so, switch to use webservices.
https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/software_dev_kit_asp_net-outside
DK Thursday, November 30, 2006
If the entire body of the page is required to be inside
<form runat="Server"/> then you have 2 options. option 1. Use HttpWebRequest and post this page behind the scenes. Side effect, you'll never see posted page's url in browser window option 2. Put <input> tags you want posted inside your document create a submit button with onClick event. Overwrite action property of the form inside OnClick button event. Side effect, javascript needs to be on, but I think this one is better than option 1.
Why not just check to see if the paypal submit button was clicked in your code behind and just do a Response.Redirect to paypal with the appropriate fields passed in on the request string?
Another option that no one has mentioned is that you could just create a separate html page for the form and embed it in your main page through an iframe.
Anonymous Thursday, November 30, 2006
I actually thought up the IFRAME idea today, independently of this thread. I did it, and it worked. Using a target="_top" ensures that the entire page reloads.
Of all the things in ASP.Net, this one drives me the most nuts. Not only does it have huge practical implementation problems, but it's really a matter of Microsoft messing with how HTTP and the GET/POST model is supposed to work. There are a lot things in ASP.Net I don't like (and I lot that I do), but this one is almost unforgivable. (I remember in another thread on this board -- about this same issue -- someone said that this problem was due to "the shaky foundations of HTTP and HTML." That may be, but they were around a *lot* longer that ASP.Net. Complaining about deficiencies in the underlying protocols is like building your house in the middle of a river and then complaining that there's water in your basement. You knew what the landscape was like before you started to build.)
This particulr issue, posting to page other than itself is fixed in asp.net 2.0. You can specify different page for posting.
Daniel Zielinski Thursday, November 30, 2006
"Of all the things in ASP.Net, this one drives me the most nuts. Not only does it have huge practical implementation problems, but it's really a matter of Microsoft messing with how HTTP and the GET/POST model is supposed to work."
I thought the limitation was with your CMS implementation. If you are just using standard .NET, you can have HTML outside of the main form body, it just can't contain server controls. So just add the paypal section using standard html outside of the main form body.
Anonymous Monday, December 04, 2006 |
|
Powered by FogBugz


