c# - Many textboxes with the same ID -


i have code below:

                <%for (int index = 1; index < 7; ++index) {%>                     <tr>                         <td>                             <div class="indicacao_gdp">                                 <asp:textbox readonly="true" id="inp_txt_indicacao_<%= index %>" cssclass="inp_txt_indicacao" runat="server" maxlength="12"></asp:textbox>                             </div>                         </td>                         <td>                             <div class="codigo_debito_credito_gdp">                                 <asp:textbox readonly="true" id="inp_txt_codigo_debito_credito_<%= index %>" cssclass="inp_txt_codigo_debito_credito" runat="server" maxlength="2"></asp:textbox>                             </div>                         </td>                         <td>                             <div class="descricao_debito_credito_gdp">                                 <asp:textbox readonly="true" id="inp_txt_descricao_debito_credito_<%= index %>" cssclass="inp_txt_descricao_debito_credito" runat="server" maxlength="2"></asp:textbox>                             </div>                         </td>                         <td>                             <div class="valor_debito_credito_gdp">                                 <asp:textbox readonly="true" id="inp_txt_valor_debito_credito_inteiro_<%= index %>" cssclass="inp_txt_valor_inteiro" runat="server" maxlength="8"></asp:textbox>                                 ,                                 <asp:textbox readonly="true" id="inp_txt_valor_debito_credito_decimal_<%= index %>" cssclass="inp_txt_valor_decimal" runat="server" maxlength="2"></asp:textbox>                             </div>                         </td>                     </tr>                 <%}%> 

but, code not working...

parser error message: 'inp_txt_indicacao_<%= index %>' not valid identifier. 

how solved?

use placeholder control , dynamically add textbox controls code-behind. in code-behind can set id , whatever other properties like.

see msdn: add controls asp.net web page programmatically.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -