Solved

Keyup function

Posted on 2013-06-21
2
349 Views
Last Modified: 2013-06-21
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
Comment
Question by:ayha1999
2 Comments
 
LVL 4

Accepted Solution

by:
AnuTiji earned 250 total points
ID: 39265183
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
 
LVL 7

Author Comment

by:ayha1999
ID: 39266434
Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now