【问题标题】:Dynamic Button On Click Event Not Firing单击事件未触发的动态按钮
【发布时间】: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>

【问题讨论】:

标签: html asp.net dynamic


【解决方案1】:

你可以用输入按钮来做这件事,一个 javascriot 的乐趣

<td><input type='button' onclick='btnActivate()' name='Activate' value='Activate' id='btnActivate(" & USERID & ")' class='activateButton' title='Activate'></td>
 ....
 
 <script type="text/javascript" language="javascript">
    function btnActivate() {
        //....
        }
   </script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 2015-10-18
    • 1970-01-01
    • 2010-10-21
    • 2013-01-17
    • 2012-03-14
    相关资源
    最近更新 更多