标签:
eg:
$(‘.setIsEnableClosed‘).click(function(){
var id=$(id).attr("name");
var isChecked=$(this).prop("checked");
$.ajax({
url:"../../ashx/Widget.ashx",
data:{‘type‘:‘setEnableClose‘,‘id‘:id,‘isChecked‘:isChecked},
cache:false,
success:function(result){
if(result==‘true‘)
success("设置成功!");
else if(data=‘sessionOut‘){
warning(‘登录超期,将跳转至登录界面!‘,function(){
setTimeout(‘window.location.href="../../login.aspx",3000‘);
});
}
else
warning("设置失败,请联系管理员");
},
error:function(){
danger("设置出错,请联系管理员");
}
})
})
.ashx :
public void ProcessRequest(HttpContext context)
{
_currentUser=contenxt.Session[SystemConfig.Account_Key] as Domin.Exchange.User;
if(_currentUser==null)
{
content.response.Write("sessionOut");
return;
}
var type=context.Requset["type"];
if(type.IsNullorEmpty())
return;
var result = Process(type, context);
if (result != null) {
context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8";
context.Response.Write(result);
}
private string Process(string type, HttpContext context)
{
_addOn = context.Request["addOn"];
switch (type) {
case "save":
return SaveWidgetInfo(context);
case "setAuthorize":
return SetAuthorize(context);
case "reset":
return Reset();
case "setEnableClose":
return SetIsEnableClose(context);
default:
return null;
}
/// <summary>
/// 设置部件是否允许删除
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
private string SetIsEnableClose(HttpContext context)
{
var id = context.Request["id"].ToInt32();
if (id < 0)
return "false";
var isChecked = context.Request["isChecked"];
bool isEnableClose=isChecked.ToBoolean();
var data = _widgetAuthorize.Get(id);
if (data != null && data.IsEnableClose!= isEnableClose)
{
data.IsEnableClose = isEnableClose;
_widgetAuthorize.Update(data);
}
return "true";
}
标签:
原文地址:http://www.cnblogs.com/sunzgod/p/4281426.html