The implementation process is as follows:
1. Quote Ajax.dll
2, in the App_Code to write specific methods, it is best to create a separate class file, and then write the specific method.
Copy Code code as follows:
public class Ajaxmethod Www.jb51.net
{
Public Ajaxmethod ()
{
//
TODO: Add constructor logic here
//
}
[Ajax.ajaxmethod (Ajax.HttpSessionStateRequirement.Read)]
public static string Getcardmoney (String cardno,string cardpwd)
{
String mconn = Iconfiguration.getparameter ("ConnectString");
Idbosql. IDBO dbo = Idbosql. Idbo.getidbo (Mconn);
Dbo.opendatabase ();
DataSet ds = Dbo.executeselectsql ("Select Card_money,service_discount,good_discount from Table_cardinfo join Dic_") Cardtype on table_cardinfo.cardtype_id= dic_cardtype.cardtype_id where card_no= ' "+cardno+" ' and Card_Pwd= ' "+cardPwd+" ' and card_status= ' normal ');
DataTable dt = ds. Tables[0];
String money = dt. Rows[0][0]. ToString ();
String service_discount = dt. ROWS[0][1]. ToString ();
String good_discount = dt. ROWS[0][2]. ToString ();
Dbo.closedatabase ();
Return money+ "," +service_discount+ ', ' +good_discount;//here Returns a string of multiple values concatenation
}
}
3, in the JS call
Copy Code code as follows:
Moneydiscount= Ajaxmethod.getcardmoney (Card, pwd). value;
moneydiscount//is a string of multiple values that, to get multiple values, can be converted to an array and then accessed.
Arr=moneydiscount.split (","); This makes it easy to use AJAX to return multiple values.
4, to return the results to the page
Copy Code code as follows:
document.getElementById ("Txtcard_money1"). Value=arr[0];
5, the above methods to be added in the Web.config file
Copy Code code as follows:
<add verb= "Post,get" path= "Ajax/*.ashx" type= "Ajax.pagehandlerfactory, Ajax"/>
Today's content is written here, later have time to write slowly