Tuesday, January 12, 2021

Using JQuery to Show And Hide Button Depend on Textbox Value in ASP.NET GridView 1

Hi Team, please try this code block. I am sure. it may be help you.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style>
    .btn{display:none}
    </style>
    
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("table[id*=GridView1] input[type=text][id*=txt]").keyup(function() {
                if ($(this).val().length > 0)
                    $(this).closest("tr").find(".btn").show();
                else
                    $(this).closest("tr").find(".btn").hide();
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField HeaderText="Text">
                <ItemTemplate>
                    <asp:TextBox ID="txt" runat="server"  />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Title">
                <ItemTemplate>
                    <asp:Button ID="Title" runat="server" CssClass="btn" Text="Button" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    </form>
</body>
</html>

No comments:

Post a Comment

No String Argument Constructor/Factory Method to Deserialize From String Value

  In this short article, we will cover in-depth the   JsonMappingException: no String-argument constructor/factory method to deserialize fro...