asp.net - How to hide a list element on linkbutton click within an asp listview control using JavaScript -
i have asp:listview control populating data databound data table in code behind create dynamic list. list have linkbutton wish bind javascript function hide corresponding li element if clicked. here html:
<asp:listview id="lstaiinsureds" runat="server"> <layouttemplate> <ul class="collection"> <asp:placeholder id="itemplaceholder" runat="server" /> </ul> </layouttemplate> <itemtemplate> <li class="collection-item" id="liremoveai"> <div> <%#eval("response").tostring().replace("|",", ")%> <asp:linkbutton id="lbremoveai" class="material-icons" clientidmode="static" onclientclick="return removeai();" runat="server">remove_circle</asp:linkbutton> </div> </li> </itemtemplate> <emptydatatemplate> <p>nothing here.</p> </emptydatatemplate> </asp:listview> and code behind being bound so:
this.lstaiinsureds.datasource = dt; this.lstaiinsureds.databind(); here current js, of course has gaps in loop need accomplish:
function removeai() { var olsremoveai = document.getelementbyid("liremoveai"); //this ls hidden var obtremoveai = document.getelementbyid("lbremoveai"); //this linkbutton clicked hide parent ls element (i = 0; < olsremoveai.???.length; i++) { //if button contained in parent li, mark li hidden: olsremoveai.style.visibility = "hidden"; olsremoveai.style.display = "none"; //else: olsremoveai.style.visibility = "visible"; olsremoveai.style.display = "block"; } return false; } is do-able? assistance appreciated!
since element lbremoveai running @ "server", need see html output of page , final client id, update javascript element id.
Comments
Post a Comment