2
我一直在试图了解发生了什么,并且我在网上搜索无济于事。如何访问ASP.net中嵌套中继器内的按钮?
如何访问嵌套中继器内的按钮?我花了很多时间研究/试验,我不明白发生了什么。
HTML标记:
<asp:Repeater runat="server" ID="repQuestionTopics">
....
<asp:Repeater ID="repQA" runat="server">
....
<strong>Was this article helpful?</strong>
<button class="button tiny secondary radius" runat="server"
CommandName="voteYes" id="btnVoteHelpfulYes">Yes</button>
<button class="button tiny secondary radius" runat="server"
CommandName="voteNo" ID="btnVoteHelpfulNo">No</button>
</asp:Repeater>
</asp:Repeater>
代码隐藏:
//Handles repQuestionTopics.ItemCommand
Public Sub repTopics_ItemCommand(Sender As Object, e As RepeaterCommandEventArgs)
If e.CommandName = "voteYes" Then
....
End If
End Sub
如何获得对repQA
访问?出于某种原因,我的代码不会让我写功能处理repQA.ItemCommand - 为什么?我曾尝试直接输入使用类似(添加的OnClick)上的ASP方面的功能:
<button class="button tiny secondary radius" runat="server" OnClick="repTopics_ItemCommand"
CommandName="voteYes" id="btnVoteHelpfulYes">Yes</button>
当按钮voteYes
点击我希望能够去到数据库并更新计数器,所以我可以跟踪该问题的答案有多少票和反对票。
无论我实施什么样的变化,当我点击按钮来尝试并使其工作,页面刷新,就是这样 - 没有别的。