[英]ASP.NET Javascript runtime error
I have just started a new ASP.NET web application and I am totally new to everything and after moving a few things round I have been getting this error and I don't understand what it means.我刚刚开始了一个新的 ASP.NET Web 应用程序,我对一切都是全新的,在移动了一些东西之后,我收到了这个错误,我不明白它的意思。
It happens when I go to enter anything in the Password box.当我在密码框中输入任何内容时会发生这种情况。
Could someone please help me out on this issue.有人可以帮我解决这个问题。
EDIT:编辑:
<li>
<asp:Label runat="server" AssociatedControlID="Password">Password</asp:Label>
<asp:TextBox runat="server" ID="Password" TextMode="Password" onkeypress="capLock(event)" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Password" CssClass="field-validation-error" ErrorMessage="The password field is required." />
</li>
document.getElementById("divMayus")
is returning null or undefined. document.getElementById("divMayus")
返回 null 或未定义。
You should look at the rendered html and find the div that you are trying to reference to make sure the id is the same as you are trying to reach.您应该查看呈现的 html 并找到您尝试引用的 div,以确保 id 与您尝试访问的 id 相同。 Asp.net alters the ids of server controls depending on their containers.
Asp.net 根据其容器更改服务器控件的 ID。 So if you moved stuff around, the id may have also been changed.
因此,如果您四处移动东西,则 id 也可能已更改。
Try to do that inside试着在里面做
window.onload = function(){
// code goes here
}
I think you are trying to access DOM even before it is being created.我认为您甚至在创建 DOM 之前就尝试访问它。
the document.getElementById('divMayus')
is undefined
document.getElementById('divMayus')
undefined
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.