我在网上找到了一些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>
请让我知道我失踪的地方?
答案 0 :(得分:1)
$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>