jquery – Block Control+V on dynamically generated TextBox fields

Question:

I have a GridView where I have several TextBox that are generated according to their total rows.

I would like to block Control+V on all TextBox .

I use Jquery 1.4 , and from what I read the on method currently used for the new Jquerys corresponds to live in Jquery 1.4 .

I tried the following code but I was not successful and there is no error in the log.

I know that each TextBox generated is also generated a different ID .

Can someone help me?

my jquery

$("#<%=tbNaoAtende.ClientID%>").live('paste',function (e) {
    e.preventDefault();
});
$("#<%=tbNaoAtendeInic.ClientID%>").live('paste', function (e) {
    e.preventDefault();
});
$("#<%=tbAtendeRess.ClientID%>").live('paste', function (e) {
    e.preventDefault();
});
$("#<%=tbAtende.ClientID%>").live('paste', function (e) {
    e.preventDefault();
});

my aspx

<asp:GridView ID="rptListaVerificacao" runat="server" PageSize="50" AutoGenerateColumns="false" SkinID="gridLV" AllowPaging="True" Width="100%">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Table ID="tbAtendimentos" runat="server" Style="font-weight: bold; border: solid 1px #c0c0c0;"
            CellPadding="5">
                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Resource, nao_atende%>"></asp:Literal>:</asp:TableCell>
                        <asp:TableCell Style="padding-right: 20px;">
                            <asp:TextBox ID="tbNaoAtende" runat="server" Width="40px" CssClass="numero"></asp:TextBox></asp:TableCell>
                        <asp:TableCell>
                            <asp:Literal ID="Literal4" runat="server" Text="<%$Resources:Resource, nao_atende_iniciativa%>"></asp:Literal>:</asp:TableCell>
                        <asp:TableCell Style="padding-right: 20px;">
                            <asp:TextBox ID="tbNaoAtendeInic" runat="server" Width="40px" CssClass="numero"></asp:TextBox></asp:TableCell>
                        <asp:TableCell>
                            <asp:Literal ID="Literal9" runat="server" Text="<%$Resources:Resource, atende_ressalva%>"></asp:Literal>:</asp:TableCell>
                        <asp:TableCell Style="padding-right: 20px;">
                            <asp:TextBox ID="tbAtendeRess" runat="server" Width="40px" CssClass="numero"></asp:TextBox></asp:TableCell>
                        <asp:TableCell>
                            <asp:Literal ID="Literal10" runat="server" Text="<%$Resources:Resource, atende%>"></asp:Literal>:</asp:TableCell>
                        <asp:TableCell Style="padding-right: 20px;">
                            <asp:TextBox ID="tbAtende" runat="server" Width="40px" CssClass="numero"></asp:TextBox></asp:TableCell>
                        <asp:TableCell>
                            <asp:LinkButton ID="lbtAtualizaAtendimento" runat="server" Text="<%$Resources:Resource, atualiza_atendimento%>"
                        OnClick="lbtAtualizaAtendimento_Click"></asp:LinkButton></asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Answer:

I got it by "class" as follows.

  $(function () {
      $(".numero").live('paste', function (e) {
                e.preventDefault();
      });
  });
Scroll to Top