c# - How to highlight page number of selected page for a linkbutton inside a repeater using pagedatasource? -
i want highlight current page number selected.
aspx code:
<asp:repeater id="rptpaging" runat="server" onitemcommand="rptpaging_itemcommand"> <itemtemplate> <asp:linkbutton id="btnpage" commandname="page" commandargument="<%# container.dataitem %>" runat="server" ><%# container.dataitem %> </asp:linkbutton> </itemtemplate> </asp:repeater>
backend code:
protected void rptpaging_itemcommand(object source, repeatercommandeventargs e) { if (e.commandname == "page") { int index = e.item.itemindex; (int = 0; < rptpaging.items.count; i++) { linkbutton btnlnk = rptpaging.items[i].findcontrol("btnpage") linkbutton; if (btnlnk != null) { btnlnk.cssclass = index == ? "page_enabled" : string.empty; } } pagenumber = convert.toint32(e.commandargument) - 1; displaydata(); } }
add attribute.. onclick="onclickpagebtnlink(this)" linkbutton. use javascript function:
function onclickpagebtnlink(sender) { sender.class = "yourhighlightclass"; var pagelinks = document.getelementsbytagname("a"); (var = 0; < pagelinks.length; i++) { if (sender.id != pagelinks[i].id) { if (pagelinks[i].id.indexof('rptpaging_btnpage_') != 0) { pagelinks[i].class = "unhighlightclass"; } } } }
you may use document.queryfor.. (i not sure of syntax) client generated anchor elements. not standard answer, work.
Comments
Post a Comment