大家好,我在加载 asp.net 时遇到了问题
我为子页面使用母版页,Materpage 中有一个表单标签,我在子页面中添加了一个PayPal按钮,这是母版页表单标签也很重要
在母版页<form id="form1" runat="server"></form>
和在苏普年龄
<form id="form2" runat="server" name="Paypal" action="https://www.paypal.com/cgi-bin
/webscr"
method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="
<%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
" />
<input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>"
/>
<input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
<input type="hidden" name="lc" value="Stronger" />
<input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
payments with PayPal - it's fast, free and secure!"
style="background: url(images/update-account.png);"/>
</form>
我在下面的子页面中遇到了错误
"/项目"应用程序中的服务器错误。一个页面只能有一个服务器端表单标记。说明:当前 Web 执行期间发生未处理的异常请求。请查看堆栈跟踪,了解有关错误及其在代码中起源位置的详细信息。
异常详细信息:System.Web.HttpException:一个页面只能有一个服务器端表单标记。
任何人都知道如何在子页面中使用表单标签。
请检查您的 aspx/html 页面上写了多少个<form>
标签。确保未为此页使用母版页。
我找到了这个解决方案,它的工作解决方案如下:
<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post" target="_blank"></form>
<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="
<%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
" />
<input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>"
/>
<input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
<input type="hidden" name="lc" value="Stronger" />
<input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
payments with PayPal - it's fast, free and secure!"
style="background: url(images/update-account.png);"/>
</form>
这段代码如我所愿地工作良好。
如果您在母版页下 只要您在表单内,就不要使用表单标记,只需将其删除,删除导致提交内容的隐藏输入,然后使用以下 ImageButton:
<asp:ImageButton ID="cmdpay" runat="server" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" Text="" ImageUrl="images/paynow.png" ></asp:ImageButton>
它有效