0

Currently I got a big list of invisible input fields, two of them got a runat="server". The names of my input fields change because of the runat="server" and the MasterPage.

See code/output below:

ASP.NET Code

<input runat="server" id="_paymentAmount" type="hidden" />
<input type="hidden" runat="server" id="_shopperEmail" />

C# Code

this._paymentAmount.Attributes.Add("name", "paymentAmount");
this._shopperEmail.Attributes.Add("name", "shopperEmail");

Other solutions I tried:

<asp:HiddenField ID="paymentAmount" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="shopperEmail" runat="server" ClientIDMode="Static" />

But in both ways this is the result:

<input id="_paymentAmount" type="hidden" value="[VALUE]" name="ctl00$_cphContent$_paymentAmount">
<input id="_shopperEmail" type="hidden" value="[VALUE]" name="ctl00$_cphContent$_shopperEmail">

And the result that I want to get is as follows:

<input id="_paymentAmount" type="hidden" value="[VALUE]" name="paymentAmount">
<input id="_shopperEmail" type="hidden" value="[VALUE]" name="shopperEmail">

Does anyone know how to resolve this issue? I cannot accept other names than paymentAmount and shopperEmail. So it's important that I can find a fix for this.

I experimented with other controls and ClientIDMode="Static".

I'm working with ASP.NET 4.5

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Rick
  • 79
  • 1
  • 8
  • Any reason why you want only `paymentAmount` as `name` value? – Bharadwaj Jun 11 '14 at 11:17
  • the value will be set in the backend and the name has to be paymmentAmount for adYen a payment service. – Rick Jun 11 '14 at 11:19
  • 1
    Related: http://stackoverflow.com/questions/7897445/can-i-force-asp-to-set-name-the-same-as-id and http://stackoverflow.com/questions/10216882/user-control-static-name-option – Tim Schmelter Jun 11 '14 at 11:21

1 Answers1

0

If you just need this field to create form that is being send to third party page then write hidden fields yourself and put the values using literals, fe.

<input type="hidden" name="paymentAmount" value="<asp:HiddenField ID="paymentAmount" runat="server"  /> " />
Łukasz W.
  • 9,538
  • 5
  • 38
  • 63