ASP.NET 和经典的 HTML 表单

发布于 2024-12-29 07:13:35 字数 2064 浏览 0 评论 0原文

我正在实施一个标准支付系统,它将一些信息发送到第三部分表格。我有一个结帐对象,它存储我所有的购物信息:ID、购买的产品、价格 - 只要你能想到的。

人们被转移到一个 ASPX 页面,该页面的实现如下所示。

目前我遇到以下问题

在具有 runat="server" 的输入上发送的值是 0。因此我收到错误。但是,在后面代码的 OnPreInit 事件中,我设置了 amount、accepturl 和 orderid 的值。我可以看到隐藏字段在页面加载时获得了正确的信息 - 但是当表单被触发时(这显然发生在 OnPreInit 事件之前),它仍然是 0。

我该如何解决这个问题?基本上我需要使用一个 HTML 表单来打开一个弹出窗口(必须在页面加载时显示),我必须在其中设置隐藏字段。应该很简单,但是在我花了几个小时之后,我真的很感激一些帮助。

目前我的实现是这样的:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BetalingMedKort.aspx.cs" Inherits="BetalingMedKort" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
        <script type="text/javascript" src="http://www.epay.dk/js/standardwindow.js"></script> 
    <title></title>
</head>


<body onload="open_ePay_window()">

    <form action="SomeUrl" runat="server" method="post" name="ePay" target="ePay_window" id="ePay">
<input type="hidden" name="merchantnumber" value="MyStaticMerchantNumber" /> 
<input type="hidden" name="language" value="1" /> 
<input type="hidden" name="currency" value="208" /> 
<input type="hidden" name="amount" id="amountField" runat="server" /> 
<input type="hidden" name="accepturl" id="acceptUrlField" runat="server" /> 
<input type="hidden" name="orderid" id="orderIdField" runat="server"  />
<input type="hidden" name="declineurl" value="SomeUrl" />

</form> 


    <div>
        If the ePay Payment Window does not open automatically please click on the button below to open it.
    <br /><br />
Notice! If you are using a pop-up blocker, you must hold down the CTRL key as you click the button.
<br /><br />
<input type="button" value="Open the ePay Payment Window" onClick="open_ePay_window()"> 
    </div>

</body>
</html>

非常感谢......

I am implementing a standard payment system, which sends some information to 3rd part form. I've a checkout object which stores all my shopping information: ID, products bought, price - you name it.

People are transfered to an ASPX page which has an implementation as seen below.

Currently I have the following problem:

The values send on the inputs which has the runat="server" is 0. Therefore I get an error. However, in the OnPreInit event in the code behind, i set the values of amount, accepturl and orderid. I can see the hidden fields get the correct information when the page is loaded - but when the form is fired (which apparently happens before the OnPreInit event), it is still 0.

How do I solve this problem? Basically I need to use an HTML form which opens a popup window (which HAS to show on page load), where I have to set the hidden fields. Should be quite simple, but after I've used hours on this I would really appreciate some help.

Currently my implementation is like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BetalingMedKort.aspx.cs" Inherits="BetalingMedKort" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
        <script type="text/javascript" src="http://www.epay.dk/js/standardwindow.js"></script> 
    <title></title>
</head>


<body onload="open_ePay_window()">

    <form action="SomeUrl" runat="server" method="post" name="ePay" target="ePay_window" id="ePay">
<input type="hidden" name="merchantnumber" value="MyStaticMerchantNumber" /> 
<input type="hidden" name="language" value="1" /> 
<input type="hidden" name="currency" value="208" /> 
<input type="hidden" name="amount" id="amountField" runat="server" /> 
<input type="hidden" name="accepturl" id="acceptUrlField" runat="server" /> 
<input type="hidden" name="orderid" id="orderIdField" runat="server"  />
<input type="hidden" name="declineurl" value="SomeUrl" />

</form> 


    <div>
        If the ePay Payment Window does not open automatically please click on the button below to open it.
    <br /><br />
Notice! If you are using a pop-up blocker, you must hold down the CTRL key as you click the button.
<br /><br />
<input type="button" value="Open the ePay Payment Window" onClick="open_ePay_window()"> 
    </div>

</body>
</html>

Thanks so much...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如若梦似彩虹 2025-01-05 07:13:35

尝试在页面的 Init 或 Load 事件中设置输入值。 ViewState 在 PreInit 期间不可用(尽管可能有一些例外)。

如果您绝对必须在 PreInit 期间执行逻辑,则此 页面 可能有适合您的解决方法。

Try setting the input values in the page's Init or Load events. ViewState isn't available during PreInit (though there may be some exceptions).

If you absolutely have to perform your logic during PreInit then this page may have a workaround for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文