我正在尝试获得一个有用的指标来在页面上工作。我可以访问按钮,但无法通过单击按钮来增加点击总数。我在后面使用 vb 代码。
这是我用来访问按钮并尝试进行某种形式的计算的代码:
Protected Sub movies_ItemCommand(source As Object, e As RepeaterCommandEventArgs) Handles movies.ItemCommand
Dim yCount As Integer
yCount = 0
Dim nCount As Integer
nCount = 0
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim btnYes As Button = CType(e.Item.FindControl("btnYes"), Button)
Dim btnNo As Button = CType(e.Item.FindControl("btnNo"), Button)
Dim lblResults As Label = CType(e.Item.FindControl("lblResults"), Label)
Dim sArgument As String = CType(e.Item.DataItem,
DataRowView).Row.Item("MovieTitle").ToString
If btnYes.OnClientClick Then
yCount = yCount + 1
MsgBox(yCount)
lblResults.Text = yCount
ElseIf btnNo.OnClientClick Then
nCount = nCount + 1
End If
total = yCount + nCount
End If
MsgBox(total)
End Sub