I get this error when e is a MouseEvent.
The HTML involving the checkbox click event in question looks like this:
<ItemTemplate> <tr style="border-top:1px solid #adadad;border-bottom:1px solid #adadad;"> <td> <asp:HiddenField runat="server" id="hfOptionProductID" value='<%#Eval("Key.ProductID")%>' /> <asp:HiddenField runat="server" id="hfOptionModelNumber" value='<%#Eval("Key.BTModel")%>' /> <asp:HiddenField runat="server" ID="hfAssetId" value='<%#Eval("Value.AssetID")%>' /> <p> <%#Eval("Key.Name")%><asp:CheckBox runat="server" id="chbxOption" class="chkOlcs" onclick="chkOlcs_onClick(e);"/> </p> <asp:Panel runat="server" ID="pnlOlcs" class="pnlOlcs" Visible="False"> <asp:CheckBox runat="server" ID="chkDomain" class="chkDomain" onclick="chkDomain_onClick(e)" Text="I want to link my license to a specific domain and its subdomains." /><br/> <asp:TextBox runat="server" ID="txtDomain" class="txtDomain" style="padding: 3px 5px; text-align: center; width: 200px;" placeholder="Enter a domain name" ValidationGroup="OptionValidationGroup" disabled /> <asp:Label runat="server" ID="lblDomainError" class="lblDomain" Visible="False" style="color: red;"/><br/> <asp:CheckBox runat="server" ID="chkAny" class="chkAny" onclick="chkAny_onClick(e)" Text="I do not want to link my license to a specific domain."/><br/> </asp:Panel> <br /> </td> </tr> </ItemTemplate>
In the HTML above, this is the problematic part:
<%#Eval("Key.Name")%>
For some unknown reason, when I debug and run this program in Visual Studio in the Edge browser, I get an error.
Somehow, e becomes undefined and the Javascript function call is never reached.
This is the Javascript function definition:
function chkOlcs_onClick(e) { var chkOlcs = $('#' + e.target.id); var pnlOlcs = chkOlcs.parent().parent().parent().find('.pnlOlcs'); var isChecked = e.target.checked; if (isChecked) { pnlOlcs.show(); } else { pnlOlcs.hide(); } }
Now to make matters worse: when running from the deployed web page, no error occurs.
I've read almost all similar questions related to this error, but none seem to apply. I'm open to any help.
P粉7855224002023-09-13 13:35:45
(unless ASP.NET does something weird (I don't use ASP.NET and you didn't mark the question as about asp .net), with the onclick
attribute) e
is not a mouse event. It is undefined. The error message tells you this.
Event
is a mouse event, but has been deprecated.
It is recommended to use addEventListener code>
instead of intrinsic event properties (such as onclick
).
element.addEventListener('click', chkOlcs_onClick)
Will pass the mouse event as the first parameter.