0

在我的 Web 应用程序中,我有母版页,它有太多的内容页面,在我的内容页面中,我想将表单发布到其他 URL。但它不会以这种方式将值发布到其他页面。

但是当我在没有母版页的简单 aspx 页面中执行相同的代码时,它运行良好。

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="frmPay">
    <div>

    <!-- Receiver Details -->
    <input type="hidden" name="merchant_id" id="merchant_id" value="xxgxg" >
    <input type="hidden" name="merchant_key" id="merchant_key" value="gxgagag" runat="server">
    <input type="hidden" name="return_url" id="return_url" value="http://www.widget.co.za/payment_finished" runat="server">
    <input type="hidden" name="cancel_url" id="cancel_url" value="http://www.widget.co.za/payment_cancelled" runat="server">
    <input type="hidden" name="notify_url" id="notify_url" value="http://www.widget.co.za/payment_notify" runat="server">

    <!-- Payer Details -->
    <input type="hidden" name="name_first" id="name_first"  value="Bob" runat="server">
    <input type="hidden" name="name_last" id="name_last" value="Smith" runat="server">
    <input type="hidden" name="email_address" id="email_address" value="bob.smith@example.com" runat="server">

    <!-- Transaction Details -->
    <input type="hidden" name="m_payment_id" id="m_payment_id" value="TRN123456789" runat="server">
    <input type="hidden" name="amount" id="amount" value="200.00" runat="server">
    <input type="hidden" name="item_name" id="item_name" value="Widget Model 123" runat="server">
    <input type="hidden" name="item_description" id="item_description" value="Widget Model 123" runat="server">

    <!-- Transaction Options -->
    <input type="hidden" name="email_confirmation" id="email_confirmation" value="" runat="server">

    <!-- Security -->
    <input type="hidden" name="signature" id="signature" value="" runat="server">
        <asp:Button ID="Button1" runat="server" PostBackUrl="https://www.payfast.co.za/eng/process" Text="Button" />
    </div>
    </form>
</asp:Content>
4

1 回答 1

0

您的<form>元素没有action=""属性 - 表单不会去任何地方(或者更确切地说,它将提交到当前 URI(无论它是什么))。如果您想将值提交到 ASP.NET 中的另一个页面,您可以阅读以下内容:http: //www.codeproject.com/Articles/14092/Cross-Page-Posting-in-ASP-NET-2-0

于 2012-10-02T06:48:51.963 回答