Wednesday, 18 April 2018

How to find closest or nearest value using Javascript in Asp.Net

closest jquery not working in ie11
Description:

In this example we explain that how to get TextBox in a table using JavaScript. Or how to get the value of the TextBox inside Gridview using JavaScript. Or how to get td value in GridView using JavaScript. Or how to get closest element using JavaScript. Many users faced is like row. Closest is not supported in Internet Explorer so we have implement that using JavaScript.

I already explain that in previous example that how to get TextBox value inside td in table or GridView using JavaScript but the problem is that it is not supported in Internet Explorer browser so to overcome this we have implement the same functionality using JavaScript.

Function: 

function DisplayDetails(row) {
            if ($(row).parent().parent().find("td").eq(0).find("span").text() != undefined && $(row).parent().parent().find("td").eq(0).find("span").text() != "") {
              $('#<%=hdnid.ClientID %>').val($(row).parent().parent().find("td").eq(0).find("input").val());
               $('#<%=hdntype.ClientID %>').val($(row).parent().parent().find("td").eq(0).find("span").text());
            }
            else {
                $('#<%=hdnid.ClientID %>').val($(row).parent().parent().eq(0).find("a").attr("id"));
                $('#<%=hdntype.ClientID %>').val($(row).parent().parent().find("td").eq(0).text());
            }
            return true;

        }

 Call Function From GridView:

<asp:TemplateField HeaderText="Project" ItemStyle-CssClass="Project">
                            <ItemTemplate>
                                <asp:LinkButton ID="popuplink" runat="server" OnClientClick="return DisplayDetails(this);"
                                    OnClick="popup_Click"> <span style="color:#333333 !important;">ℹ️</span></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>





0 comments:

Post a Comment