Solved

Keyup function

Posted on 2013-06-21
2
350 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

895 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

14 Experts available now in Live!

Get 1:1 Help Now