内容模板上的Accordian extender和javascript事件
快速进入代码,下面是accordian的asp.net标记,它将主题标题作为每个窗格的标题,其内容是要调整的注释内容模板上的Accordian extender和javascript事件,javascript,asp.net,ajax,events,Javascript,Asp.net,Ajax,Events,快速进入代码,下面是accordian的asp.net标记,它将主题标题作为每个窗格的标题,其内容是要调整的注释 <ajaxToolkit:Accordion runat="server" id="accCommentTrash" fadetransitions="true" selectedindex="-1" requireopenedpane="false" autosize="None" headercssc
<ajaxToolkit:Accordion runat="server" id="accCommentTrash" fadetransitions="true"
selectedindex="-1" requireopenedpane="false" autosize="None" headercssclass="accTitle"
headerselectedcssclass="accSelectedTitle">
<HeaderTemplate>
<h4>
Title:(<%# ((System.Data.DataRowView)Container.DataItem)["Title"]%>)</h4>
</HeaderTemplate>
<ContentTemplate>
<asp:Repeater runat="server" id="rptrComments" datasource='<%# ((System.Data.DataRowView)Container.DataItem).CreateChildView("CommentRelation") %>'>
<HeaderTemplate>
<ul class="comment_trash">
</HeaderTemplate>
<ItemTemplate>
<li id='<%# new Utilities().encrypt(((System.Data.DataRowView)Container.DataItem)["CommentId"].ToString()) %>'
name='<%# new Utilities().encrypt(((System.Data.DataRowView)Container.DataItem)["CommentId"].ToString()) %>'>
<asp:Label id="lblCommentor" runat="server" text='<%# ((System.Data.DataRowView)Container.DataItem)["AuthorName"] %>'
cssclass=""></asp:Label>
<span>Commented on </span><a href='?id=<%# new Utilities().encrypt(((System.Data.DataRowView)Container.DataItem)["BoardId"].ToString())%>'
title="Click to view board" class="">
<%# ((System.Data.DataRowView)Container.DataItem)["Title"] %>
</a>
<p>
<asp:Label runat="server" id="lblComment" text='<%# ((System.Data.DataRowView)Container.DataItem)["Comment"] %>'
cssclass=""></asp:Label>
</p>
<p>
Trashed about
<%# GetTimeSpan(DateTime.Now,((System.Data.DataRowView)Container.DataItem)["ModifiedOn"].ToString()) %>
hours ago, Commented on
<%# DateTime.Parse(((System.Data.DataRowView)Container.DataItem)["CreatedOn"].ToString()).ToLongDateString() %>
</p>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</ajaxToolkit:Accordion>
现在我做错了什么,在这里。Firebug向我显示了事件列表,但没有触发事件:(这是因为Accordian在方法发生时通过调用
event.preventDefault
阻止了事件的发生。我将控件更改为repeater并解决了它
//comment restore
if ($get("<%= accCommentTrash.ClientID%>")) {
var li = $get("<%= accCommentTrash.ClientID%>").getElementsByTagName("li");
console.log(li);
for (iloopCounter = 0; iloopCounter < li.length; iloopCounter++) {
$addHandlers(li[iloopCounter], {
mouseover: ul_li_hover,
mouseout: ul_li_hover
});
$addHandler(li[iloopCounter],"click",restoreComment);
}
}
function restoreComment(evnt){
console.log(this.name);
console.log(this.id);
}