Asp.net 如何从WebForms发布到外部URL并从服务器提供值
在过去的几年里,我一直生活在一个MVC的世界里,我无法回到WebForms的世界 我必须尝试将外部支付方式集成到4步流程中。最后一步涉及将一些值发布到给定的URL。此URL需要具有预定义名称的预设值列表(即,我无法更改它所需的值) 我遇到的问题是在我要发布的表单上填充从步骤1-3获得的值 假设我需要发送3个值(有更多值,但原理相同): 我可以写一份表格Asp.net 如何从WebForms发布到外部URL并从服务器提供值,asp.net,webforms,Asp.net,Webforms,在过去的几年里,我一直生活在一个MVC的世界里,我无法回到WebForms的世界 我必须尝试将外部支付方式集成到4步流程中。最后一步涉及将一些值发布到给定的URL。此URL需要具有预定义名称的预设值列表(即,我无法更改它所需的值) 我遇到的问题是在我要发布的表单上填充从步骤1-3获得的值 假设我需要发送3个值(有更多值,但原理相同): 我可以写一份表格 <form action="http://url/goes/here"> <p>Please confirm t
<form action="http://url/goes/here">
<p>Please confirm the details below</p>
<asp:TextBox id="amount" runat="server" />
<asp:TextBox id="returnurl" runat="server" />
<asp:TextBox id="name" runat="server" />
<asp:Button id="submitme" />
</form>
请确认以下详细信息
并且可以从PageLoad
上的codebehind轻松地预先填充文本框(或标签,或我需要的任何内容)
但随后提交的值前缀为“ctl00$ContentBottom$WebFormControl$ctl00$”,因此外部url将其丢弃,并抱怨没有提供任何值。它看到的是“ctl00$ContentBottom$WebFormControl$ctl00$amount”,而不是“amount”
我是否可以修改发布的值的名称?您可以在您的aspx页面中添加它们,而不是修改值的名称,如下所示
<input type="hidden" name="billing_cust_name" value="<%=txtbox1.Text%>">
<input type="hidden" name="billing_cust_address" value="<%=txtbox2.Text%>" >
<input type="hidden" name="billing_cust_email" value="<%=txtbox3.Text%>">
<input type="hidden" name="billing_cust_notes" value="<%=txtbox4.Text%>">
当表单准备过账时,更改值,然后过账
<input type="hidden" name="billing_cust_name" value="<%=txtbox1.Text%>">
<input type="hidden" name="billing_cust_address" value="<%=txtbox2.Text%>" >
<input type="hidden" name="billing_cust_email" value="<%=txtbox3.Text%>">
<input type="hidden" name="billing_cust_notes" value="<%=txtbox4.Text%>">