不能通过后台的到的json值来判断应该弹出什么样的alert();
fieldLabel: "集团登录名",
id: "groupTypeID",
width: 150,
allowBlank: false, //如果是true,则允许,否则不允许,默认是true
blankText: "请输入集团登录名!", //如果allowBlank 设置为true,并且那个textField的值为空,则会显示blankText属性的字符串以给出错误提示
emptyText: "请输入集团登录名!",
listeners: {
"blur": function() {
var group = Ext.getCmp("groupTypeID").getValue();
//Ext.Msg.alert(group); Ext.Ajax.request({
url: "../ajax/mapHandler.ashx?action=checkGrouptypeId",
params: { paramtype: group },
success: function(responses) {
if (obj == "已存在") {
Ext.Msg.alert("提示", "此集团登录名不可用!", function() {
Ext.getCmp("groupTypeID").setValue();
Ext.getCmp("groupTypeID").focus();
//groupTypeID.disable();
});
//return;
}
},
failure: function(response) {
//Ext.Msg.alert("false");
}
});
}
}
////////////////////////
后台代码:
%@ WebHandler Language="C#" Class="mapHandler" %>using System;
using System.Web;
using GPSManagerModels;
using System.Collections.Generic;
using GPSManagerBLL;
using System.Web.SessionState;
using Newtonsoft.Json;
public class AddDeviceHandler : IHttpHandler { GISGroupInfoManager gim = new GISGroupInfoManager();
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (HttpContext.Current == null)
{
throw new NullReferenceException("The context is not set correct in ProcessRequest().");
}
string str = context.Request["action"].ToString();
switch (str) {
case "getMap":
this.getMap();
return;
case "checkGrouptypeId":
string groupTypeID = context.Request["paramtype"].ToString();
this.checkGroupTypeID(groupTypeID);
return;
case "":
return;
}
}
public bool IsReusable {
get {
return false;
}
} private void checkGroupTypeID(string grouptypeid) {
if (grouptypeid != null && grouptypeid != "")
{
int count = gim.checkGroupTypeID(grouptypeid);
if (count > 0)
{
//bool result = true;
string res = "{success:true}";
HttpContext.Current.Response.Write(res);
}
else {
//bool result = false;
string res = "{success:false}";
HttpContext.Current.Response.Write(res);
}
}
}}
fieldLabel: "集团登录名",
id: "groupTypeID",
width: 150,
allowBlank: false, //如果是true,则允许,否则不允许,默认是true
blankText: "请输入集团登录名!", //如果allowBlank 设置为true,并且那个textField的值为空,则会显示blankText属性的字符串以给出错误提示
emptyText: "请输入集团登录名!",
listeners: {
"blur": function() {
var group = Ext.getCmp("groupTypeID").getValue();
//Ext.Msg.alert(group); Ext.Ajax.request({
url: "../ajax/mapHandler.ashx?action=checkGrouptypeId",
params: { paramtype: group },
success: function(responses) {
if (obj == "已存在") {
Ext.Msg.alert("提示", "此集团登录名不可用!", function() {
Ext.getCmp("groupTypeID").setValue();
Ext.getCmp("groupTypeID").focus();
//groupTypeID.disable();
});
//return;
}
},
failure: function(response) {
//Ext.Msg.alert("false");
}
});
}
}
////////////////////////
后台代码:
%@ WebHandler Language="C#" Class="mapHandler" %>using System;
using System.Web;
using GPSManagerModels;
using System.Collections.Generic;
using GPSManagerBLL;
using System.Web.SessionState;
using Newtonsoft.Json;
public class AddDeviceHandler : IHttpHandler { GISGroupInfoManager gim = new GISGroupInfoManager();
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (HttpContext.Current == null)
{
throw new NullReferenceException("The context is not set correct in ProcessRequest().");
}
string str = context.Request["action"].ToString();
switch (str) {
case "getMap":
this.getMap();
return;
case "checkGrouptypeId":
string groupTypeID = context.Request["paramtype"].ToString();
this.checkGroupTypeID(groupTypeID);
return;
case "":
return;
}
}
public bool IsReusable {
get {
return false;
}
} private void checkGroupTypeID(string grouptypeid) {
if (grouptypeid != null && grouptypeid != "")
{
int count = gim.checkGroupTypeID(grouptypeid);
if (count > 0)
{
//bool result = true;
string res = "{success:true}";
HttpContext.Current.Response.Write(res);
}
else {
//bool result = false;
string res = "{success:false}";
HttpContext.Current.Response.Write(res);
}
}
}}
if(obj.success){
Ext.Msg.alert("提示","已存在")
}