Solved

Keyup function

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
isNaN issue on the Table input text 2 38
Using the .NET JSON Serializer to create a single string 6 53
Form submit takes only for one form 23 45
Slow Down an Animation 3 25
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

738 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