Ajax调用例子

Ajax.cs

 public class Ajax {

        public Ajax() { }

        [AjaxPro.AjaxMethod]
        public static string GetText1(string a){
            return "aa";
        }

        [AjaxPro.AjaxMethod]
        public static bool CheckUserCoin() {
            string userCode = SessionHelper.Get(SessionHelper.USERCODE);
            int c = SqlHelper.GetUserCoin(userCode);

            if (PublicFunction.GetIsAdmin(userCode))
                return true;

            if (!SqlHelper.IsPayUser(SessionHelper.Get(SessionHelper.USERCODE)) && c < 10) {
                return false;
            }

            return true;
        }

        [AjaxPro.AjaxMethod]
        public static void PayCoin() {
            string userCode = SessionHelper.Get(SessionHelper.USERCODE);

            if (!PublicFunction.GetIsAdmin(userCode)) { 
                SqlHelper.PayCoin(userCode);
            }
        }
    }

Show.aspx

function vphone() {
         var check = Cleo.Ajax.CheckUserCoin().value;
         if (!check) {
             window.alert('用户积分不够');
             window.location.href = '../Default.aspx';
             return;
         }
        var v = document.getElementById("<%=i_contact.ClientID %>").value;
         $("#phone").html(v);

         Cleo.Ajax.PayCoin();
    }





你可能感兴趣的:(ASP.NET,Function)