?
Solved

Keyup function

Posted on 2013-06-21
2
Medium Priority
?
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
AnuTiji earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

752 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