Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中的Window.Alert()不起作用_Javascript_Asp.net_Alert - Fatal编程技术网

javascript中的Window.Alert()不起作用

javascript中的Window.Alert()不起作用,javascript,asp.net,alert,Javascript,Asp.net,Alert,我在网上找到了一些javascript代码。我正在使用它,但在这里我无法获取windows.alert()方法。下面是我的代码 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Javascriptexmple.aspx.cs" Inherits="MIS_Javascriptexmple" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transition

我在网上找到了一些javascript代码。我正在使用它,但在这里我无法获取windows.alert()方法。下面是我的代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Javascriptexmple.aspx.cs"     Inherits="MIS_Javascriptexmple" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script language="javascript" type="text/javascript">
  function Validate() {
      // Get the password entered in the page
      var Pass = $get("MyPass").value;
      // Encrypte the password
      var MD5 = hex_md5(Pass);
      // Run ValidateLogin PageMethod to validate the password
      PageMethods.ValidateLogin(MD5, Done);
      window.alert(MD5);
  }
  function Done(result) {
      // Alert the boolean result returned from PageMethod
      alert(result);
  }
  </script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
    <asp:ScriptManager EnablePageMethods="true" ID="ScriptManager1" runat="server">
    <Scripts>
      <asp:ScriptReference Path="md5.js" />
    </Scripts>
  </asp:ScriptManager>

<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
      <asp:TextBox ID="MyPass" runat="server"></asp:TextBox>
      <input id="BtnLogin" type="button" value="Login" onclick="Validate();" />
    </ContentTemplate>
  </asp:UpdatePanel>
</div>
</form>

函数验证(){
//获取在页面中输入的密码
var Pass=$get(“MyPass”).value;
//加密密码
var MD5=十六进制MD5(通过);
//运行ValidateLogin PageMethod验证密码
PageMethods.ValidateLogin(MD5,完成);
窗口警报(MD5);
}
功能完成(结果){
//警告PageMethod返回的布尔结果
警报(结果);
}


请告诉我丢失的位置?

$get
未定义<未定义代码>十六进制md5<代码>页面方法。未定义ValidateLogin。 包括定义这些函数的脚本,您应该可以开始了。像这样:

<script src="md5script.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
  function Validate() {
      // Get the password entered in the page
      var Pass = $get("MyPass").value;
      // Encrypte the password
      var MD5 = hex_md5(Pass);
      // Run ValidateLogin PageMethod to validate the password
      PageMethods.ValidateLogin(MD5, Done);
      window.alert(MD5);
  }
  function Done(result) {
      // Alert the boolean result returned from PageMethod
      alert(result);
  }
  </script>

函数验证(){
//获取在页面中输入的密码
var Pass=$get(“MyPass”).value;
//加密密码
var MD5=十六进制MD5(通过);
//运行ValidateLogin PageMethod验证密码
PageMethods.ValidateLogin(MD5,完成);
窗口警报(MD5);
}
功能完成(结果){
//警告PageMethod返回的布尔结果
警报(结果);
}

检查浏览器的JS控制台,查看在该点之前是否发生任何JS错误。如果没有ASP.net组件,很难重新创建此错误。我同意上面的评论,先检查JS错误是否发生。如果这没有帮助,建议您使用JSFIDLE重新发布,仅限于失败的代码。否。它没有显示任何错误。我在这里找到了上面的解决方案。在浏览器中查看站点时,单击“查看源”。查找ScriptReference所在的行。单击md5.js源代码。您的浏览器中是否存在该文件?它是否定义了$get、hex_md5和PageMethods.ValidateLogin方法?我将window.alert(md5)放进去;在PageMethods.ValidateLogin之前(MD5,完成);现在它正在变干。