后台的
namespace Ext_js
{
[AjaxPro.AjaxNamespace("AppAjax")]
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//注册AJax
if (!Page.IsPostBack)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(Default));
}
}
//判断用户名密码是否正确
[AjaxPro.AjaxMethod]
public Boolean Login(string username, string pwd)
{
if (username == "admin" && pwd == "1234")
{
return true;
}
else
{
return false;
}
}
}
}
前台的
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Ext_js.Default" %>
<!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">
<link href="ExtJS/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
<script src="ExtJS/bootstrap.js" type="text/javascript"></script>
<script src="ExtJS/ext-all.js" type="text/javascript"></script>
<title></title>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function () {
var p = Ext.create('Ext.ProgressBar', {
renderTo: Ext.getBody(),
width: 300
});
// 等待五秒,然后更新状态元素(进度条会自动复位)
p.wait({
interval: 500, //非常快地移动!
duration: 5000,
increment: 15,
text: '更新中.',
scope: this,
fn: function () {
p.updateText('更新完毕!');
}
});
var formPanel = new Ext.FormPanel({
id: 'vali',
labelWidth: 75, // label settings here cascade unless overridden
frame: true,
bodyStyle: 'padding:5px 5px 0',
width: 350,
height: 80,
defaults: { width: 230 },
defaultType: 'textfield',
items: [{ id: 'username', fieldLabel: '用户名', name: 'username', allowBlank: false, blankText: '必填' },
{ id: 'password', fieldLabel: '密 码', name: 'password', allowBlank: false, blankText: '必填'}]
})
var win = new Ext.Window({
title: '请登录',
width: 380,
autoHeight: 'true',
resizable: false,
modal: true,
closeAction: 'hide',
buttonAlign: 'center',
items: formPanel,
buttons: [{ text: '确定', handler: function () {
var name = Ext.getCmp('username').getValue();
var pwd = Ext.getCmp('password').getValue();
Ext.Msg.alert("调用后台方法<br>参数1:"+name+"<br> 参数2:"+pwd);
**if (Ext_js.Default.Login(name, pwd))** {
Ext.Msg.alert("登录成功!");
window.location.href = 'login.aspx';
} else {
Ext.Msg.alert("密码或账号错误!");
}
Ext.Msg.alert("验证完毕");
}
}, { text: '取消', handler: function () { win.hide(); } },
{ text: '重置', handler: function () {
Ext.getCmp('username').setValue("");
Ext.getCmp('password').setValue("");
}
}]
})
win.show();
});
</script>
</body>
</html>
配置文件
<!--配置AjaxPro-->
<httpHandlers>
<add path="ajaxpro/*.ashx" verb="POST,GET" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
求解一下 哪里出问题了
在if (Ext_js.Default.Login(name, pwd))这里都不执行