ASP.NET页面中的POST表单 [英] form POST in ASP.NET page

查看:63
本文介绍了ASP.NET页面中的POST表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的.aspx页中实施贝宝付款.我的页面中包含以下html:

I am trying to implement a paypal payment in my .aspx page. I have the following html in my page:

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_xclick">
  <input type="hidden" name="hosted_button_id" value="19218">
  <input type="hidden" name="rm" value="2">
  <input type="hidden" name="business" value="<%= ConfigurationManager.AppSettings("BusinessEmail").ToString%>">
  <input type="hidden" name="item_name" value="<%= "CityBits Gold " & listplans.SelectedItem.ToString & " listing plan for " & trim(txttitle.text)%>">
  <input type="hidden" name="item_number" value="<%= HiddenFieldid.Value%>">
  <input type="hidden" name="amount" value="<%= listplans.SelectedValue%>">
  <input type="hidden" name="currency_code" value="EUR">
  <input type="hidden" name="return" value="<%= ConfigurationManager.AppSettings("ReturnUrl").ToString & "?requestID=" & HiddenFieldid.Value%>">
  <input type="hidden" name="cancel_return" value="<%= ConfigurationManager.AppSettings("CancelUrl").ToString%>">
  <input type="hidden" name="no_shipping" value="1">
  <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="">
  <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

在我的aspx页面中,当我单击paypal按钮时,它只是刷新页面.当我将完全相同的代码(当然带有实际值)放在纯HTML文件中并单击按钮时,它会根据需要将我重定向到Paypal.我已经尝试使用实际值作为输入,就像在html页面中一样,但仍然无法正常工作.

In my aspx page, when i click the paypal button, it just refresh the page. When I put the exact same code (with actual values of course) in a plain html file and click the button, it redirect me to paypal as desired. I have tried using actual values for inputs just like in the html page, but it still does not work.

如果有关系,我的页面上有更新面板,但此表格不在其中.

if it matters, I have update panels in my page, but this form is not inside them.

有人知道我在做什么错吗?可能有些愚蠢,但这现在让我头痛了2天!

Anyone knows what I am doing wrong? It might be something stupid, but this is giving me headaches for 2 days now!

推荐答案

这里的问题是ASP.NET页的工作方式. ASP.NET始终仅假定页面上有一种大格式,并在引入第二种形式时开始执行各种技巧.

The problem here is the way ASP.NET pages work. ASP.NET always assumes only one large form on the page, and begins to perform various tricks when you introduce a second one.

但是,在您的情况下可以使用的是Button控件及其

However what you can use in your case is a Button control and its PostBackUrl property. It will handle your inner form correctly, gathering all parameters and performing a post:

<form target="paypal">
  ...
  <asp:ImageButton runat="server" ID="PayPalSubmit"
                   PostBackUrl="https://www.paypal.com/cgi-bin/webscr"
                   ImageUrl="https://www.sandbox.paypal.com/en_US/i/btn/btn_cart_LG.gif" />
</form>

这篇关于ASP.NET页面中的POST表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆