[英]ASP.NET and the classic HTML form
我正在實施一個標准的付款系統,該系統會將一些信息發送到第三部分表格。 我有一個結帳對象,其中存儲了我所有的購物信息:ID,購買的商品,價格-隨便命名。
人們被轉移到ASPX頁面,該頁面具有如下所示的實現。
目前,我有以下問題 :
在具有runat =“ server”的輸入上發送的值是0。因此出現錯誤。 但是,在后面代碼中的OnPreInit事件中,我設置了value,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>
非常感謝...
嘗試在頁面的Init或Load事件中設置輸入值。 在PreInit期間,ViewState不可用(盡管可能會有一些例外)。
如果您絕對必須在PreInit期間執行邏輯,則此頁面可能為您提供解決方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.