【发布时间】:2014-06-11 11:12:55
【问题描述】:
目前我有一大堆不可见的输入字段,其中两个有一个 runat="server"。 由于 runat="server" 和 MasterPage,我的输入字段的名称发生了变化。
见下面的代码/输出:
ASP.NET 代码
<input runat="server" id="_paymentAmount" type="hidden" />
<input type="hidden" runat="server" id="_shopperEmail" />
C#代码
this._paymentAmount.Attributes.Add("name", "paymentAmount");
this._shopperEmail.Attributes.Add("name", "shopperEmail");
我尝试过的其他解决方案:
<asp:HiddenField ID="paymentAmount" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="shopperEmail" runat="server" ClientIDMode="Static" />
但在这两种情况下,结果都是这样的:
<input id="_paymentAmount" type="hidden" value="[VALUE]" name="ctl00$_cphContent$_paymentAmount">
<input id="_shopperEmail" type="hidden" value="[VALUE]" name="ctl00$_cphContent$_shopperEmail">
而我想要得到的结果如下:
<input id="_paymentAmount" type="hidden" value="[VALUE]" name="paymentAmount">
<input id="_shopperEmail" type="hidden" value="[VALUE]" name="shopperEmail">
有谁知道如何解决这个问题?除了 paymentAmount 和 shopperEmail,我不能接受其他名称。因此,重要的是我可以找到解决此问题的方法。
我尝试了其他控件和 ClientIDMode="Static"。
我正在使用 ASP.NET 4.5
【问题讨论】:
-
有什么理由只希望
paymentAmount作为name值? -
该值将在后端设置,名称必须为 adYen 支付服务的 paymmentAmount。