cs中的ajax


1.注册
AjaxManager.Register(this,"ReaderAJAX");
2. 声明方法:
a.没有返回值
  [AjaxMethod(IncludeControlValuesWithCallBack=false)]
  public void MarkPostRead(int feedId)
  {
   if(csContext.IsAuthenticated && feedId != 0)
    FeedReaderDataProvider.Instance().MarkPostRead(csContext.User.UserID, feedId);
  }
b.有返回值:
  [AjaxMethod(IncludeControlValuesWithCallBack=true)]
  public virtual string[] AddFavoriteUser(int userID)
  {
   Favorite f = new Favorite();
   f.ApplicationType = this.ApplicationType;
   f.FavoriteType = FavoriteType.User;
   f.ItemID = userID;
   f.SettingsID = csContext.SiteSettings.SettingsID;
   f.UserID = csContext.User.UserID;

   Favorites.AddFavorite(f);

   string[] result = new string[2];
   User user = Users.GetUser(this.UserID, false);

   result[0] = String.Format(ResourceManager.GetString("FavoritePopupMenu_User_Remove"), user.DisplayName);
   result[1] = string.Format(ajaxCommand, "RemoveFavoriteUser", this.UserID, this.ClientID);

   return result;
  }
3.js中调用:
 ReaderAJAX.DeleteFeed(controlClientID, args1,args2,......., this.ProcessAjaxResponse);
  

 this.ProcessAjaxResponse = function(result)
 {
  if (result.error)
   alert(result.error);
        else
  {
   result.value[0];*********
  }

 }

posted @ 2007-07-04 15:57  烈马狂生  阅读(248)  评论(0编辑  收藏  举报