Get Textbox value inside the Repeater with Javascript Event Onchange

Asked

Viewed 174 times

0

Good afternoon, I’m not getting past the value of a TextBox asp.net created within a Repeater as a parameter for a function javascript event onchange. I need to pass two parameters the first is one Eval("PostID") which works perfectly, but the second parameter is the value of the TextBox I can’t pass it. Someone could give a hint.

Front-end image: inserir a descrição da imagem aqui

<asp:Repeater ID="Repeater2" runat="server">
    <HeaderTemplate>
        <table id="repeaterTable" style="border: 1px solid black;">
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td style="border-collapse: collapse; border: 1px solid black;">
                <div class="img-push">
                    <asp:TextBox CssClass="form-control input-sm"
                        placeholder="Pressione enter para postar comentário"
                        ID="txtPost" runat="server" 
                        onchange='<%# String.Format("FunctionComment(\"{0}\", "\{1}\");", 
                        Eval("PostID"), TextBoxAQUI) %> '>
                    </asp:TextBox>                    
                </div>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

inserir a descrição da imagem aqui

1 answer

1


Try it this way:

<asp:Repeater ID="Repeater2" runat="server">
    <HeaderTemplate>
        <table id="repeaterTable" style="border: 1px solid black;">
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td style="border-collapse: collapse; border: 1px solid black;">
                <div class="img-push">
                    <asp:TextBox CssClass="form-control input-sm"
                        placeholder="Pressione enter para postar comentário"
                        ID="txtPost" runat="server" 
                        onchange='<%# String.Format("FunctionComment(\"{0}\", this.value);", 
                        Eval("PostID")) %> '>
                    </asp:TextBox>                    
                </div>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
  • was not, the second parameter remains empty. I have tried this and this.value but the value of the text field does not take. See in the new image attached.

  • tried again your code now was yes! Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.