我在网上找到了一些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>
请告诉我我遗漏了哪里?
发布于 2014-08-29 13:11:42
未定义$get
。未定义hex_md5
。未定义PageMethods.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>
https://stackoverflow.com/questions/25561966
复制相似问题