• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

Keyup function

Hi,

I am trying to disable a button when change a textbox control value inside a gridView control in an aspx page. when I change value in the textbox in the first row of the gridview it disables the button but not for any other rows. Please help me to fix the problem.

script
    <script>
        $(document).ready(function () {
            $("#txtScale").keyup(function () {
                $("#btnQuote").attr('disabled', 'disabled');
            });
        });

    </script>

Open in new window


html
    <asp:GridView ID="gvFiles" runat="server" AutoGenerateColumns="False" BackColor="White"
                    BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black"
                    GridLines="Vertical" OnRowDeleting="Delete" DataKeyNames="id" Width="682px">
                    <AlternatingRowStyle BackColor="#CCCCCC" />
                    <Columns>
...
                        <asp:TemplateField HeaderText="Scale">
                            <ItemTemplate>
                                <asp:TextBox ID="txtScale" runat="server" Text="1" ClientIDMode="Static"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>

   </Columns>
...
                </asp:GridView>

Open in new window


Thanks

ayha
0
ayha1999
Asked:
ayha1999
1 Solution
 
AnuTijiCommented:
Hi

You can fix the problem by providing a class to the textbox and then link the key up event with the css class.  I have pasted the code below:

CssClass
---------------
.txtClass
{
  text-align:left;
}
<script>
        $(document).ready(function () {
            $(".txtClass").keyup(function () {
                $("#btnQuote").attr('disabled', 'disabled');
            });
        });
</script>

 <asp:GridView ID="gvFiles" runat="server" AutoGenerateColumns="False" BackColor="White"
                    BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black"
                    GridLines="Vertical" OnRowDeleting="Delete" DataKeyNames="id" Width="682px">
                    <AlternatingRowStyle BackColor="#CCCCCC" />
                    <Columns>
...
                        <asp:TemplateField HeaderText="Scale">
                            <ItemTemplate>
                                <asp:TextBox ID="txtScale" runat="server" Text="1" ClientIDMode="Static" CssClass="txtClass"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>

   </Columns>
...
                </asp:GridView>
0
 
ayha1999Author Commented:
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now