locked
Automatic attribute change 'name' RRS feed

  • Question

  • User2142405843 posted

    Hi, all!
    I need filling values of input fields from .cs code for it I added 'runat="server' for inputs.

    I have aspx page with form on it:

    <form action="https://money.yandex.ru/eshop.xml" method="post">
        <input name="shopId" value="00000" type="hidden" required/>
        <input name="scid" value="00000" type="hidden" required/>
        <input runat="server" id="inpOrderNumber" name="orderNumber" value="0" type="hidden" required/>
        <input runat="server" id="inpCustNumber" type="hidden" required name="customerNumber" value="" size="64"/><br>
        <input type="submit" value="Оплатить">
    </form>

    when I opening the .aspx page then value in attribute 'name' changing to value from attribute 'id'. How it fix?
    For example:
    - in source <input runat="server" id="inpOrderNumber" name="orderNumber" value="0" type="hidden" required/>
    - after open page <input runat="server" id="inpOrderNumber" name="inpOrderNumber" value="0" type="hidden" required/>

    Wednesday, November 21, 2018 2:42 AM

All replies

  • User-821857111 posted

    You can either remove runat="server" from the affected controls, or change the id so that it is the same as the name.

    Wednesday, November 21, 2018 8:02 AM
  • User2142405843 posted

    Many thanks!

    Wednesday, November 21, 2018 12:24 PM
  • User1281381861 posted

    when I opening the .aspx page then value in attribute 'name' changing to value from attribute 'id'

    Thats how ASP.NET behaves and set a unique id and name based id if it is a server control. It gets the name based on its Naming container.

    Saturday, November 24, 2018 10:03 AM