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(); }
<a href="javascript:;" id="vphone" onclick="vphone()"></a>