Friday, 18 January 2013 13:56

how to show/hide panel inside datalist using jquery

Written by 
Rate this item
(1 Vote)

if you wanted to use jquery like for showing/hiding panel
when button clicked inside datalist itemtemplate then you
experienced that the action is repeated per item.

following example shows how to overcome this problem and
how to use jquery in datalist itemtemplate.

<script type="text/javascript" language="javascript">
$(document).ready(function () {
$(".linkreply").live("click", function (evt) {
evt.preventDefault(); //this prevents the
//click from leave the page

$(this).next().show("slow"); // show the panel

<asp:DataList ID="DataList1">
<asp:LinkButton ID="Reply" Font-Size="9" CssClass="linkreply" runat="server"
<asp:Panel ID="Nonusercomment2" Font-Size="9" CssClass="subcommentstyle" runat="server">
<asp:Label ID="namelabel2" runat="server" resourcekey="Name" /><br />
<asp:TextBox ID="NameTextBox2" EnableViewState="false"
CssClass="allsubcommentboxes" runat="server" /><br />

in the script section this line - evt.preventDefault();
prevents the click from leaving the page.

Read 3866 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.