【发布时间】:2020-12-28 08:57:17
【问题描述】:
我在单击按钮时无法触发 onclick 事件。我可以很好地看到页面上的按钮,但永远不会调用该操作。如果有人能指出我正确的方向,我将不胜感激
// This is adding it to my existing table and trying to generate the button with the on click event
// I am looping through a list of users and trying to add an activate button for each of them
If mycount < 3 Then
litExpiredUser.Text += "<td><input type='button' onclick='btnActivate' name='Activate' value='Activate' id='btnActivate(" & USERID & ")' class='activateButton' title='Activate'></td>"
End If
Protected Sub btnActivate_Click(UserID)
{
// Performing My Activation work
// When done Calling Page Refresh to show new activations
}
// This is where I call the control to show my table on the page
<asp:Literal ID="litExpiredAccess" runat="server"></asp:Literal>
【问题讨论】:
-
您需要创建实际的 aspnet 按钮,而不是像 html 一样的按钮,例如
Button button = new Button();。请参阅此处的示例stackoverflow.com/questions/42563426/…