<script type="text/javascript"> jQuery(function ($) { $('a.lnk_showCheck').click(function (e) { e.preventDefault(); $('div', $(this).closest("td").next()).show(); }); }); </script> <script type="text/javascript"> function ShowCheck() { $('div', $(this).closest("td").next()).show(); }; </script>
<asp:DataList ID="MyDataList" runat="server" EnableViewState="True"> <HeaderTemplate> </HeaderTemplate> <ItemTemplate> <table width="100%"> <tr id="ItemRow" runat="server"> <td > <asp:LinkButton Text="Update" class="lnk_showCheck" CommandName="update" Runat="server" ID="update" /> </td> <td > <div id="check" style="display: none">Check</div> </td> </tr> </table> </ItemTemplate> </asp:DataList>
The first function
$('a.lnk_showCheck').click(function (e) {
works for Linkbutton inside a DataList. But I need to use second function ShowCheck() to call it from a server side function.
Protected Sub MyDataList_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles MyDataList.ItemCommand If e.CommandName = "update" Then Dim script As String = "<script language='javascript'> ShowCheck();</script>" Page.ClientScript.RegisterStartupScript(Me.[GetType](), "ShowCheck", script, False) End If End Sub
Variable $(this)
represents different object in both functions.
How could I construct jquery function ShowCheck() for getting and showing div?