In this project, many problems have been solved step by step through hard work. Calm down and make a record for future study.
If you encounter a problem in the project, you need to read the value in the database in JS and then return the value to the page. The solution is as follows: Ajax is used for implementation and ajax is required. dll (a help class library for ajax technology development ).
The implementation process is as follows:
1. Reference Ajax. dll
2. Write a specific method in App_Code. It is best to create a class file separately and then write a specific method.
Public class AjaxMethod www.2cto.com
{
Public AjaxMethod ()
{
//
// TODO: add the 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.exe cuteSelectSql ("select Card_Money, Service_Discount, good_Discount from Table_CardInfo join Dic_CardType on Table_CardInfo.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; // return a string concatenated by multiple values.
}
}
3. Call in JS
Moneydiscount = AjaxMethod. GetCardMoney (card, pwd). value;
Moneydiscount is a string concatenated by multiple values. To obtain multiple values, you can convert the string into an array and then access it.
Arr = moneydiscount. split (","); in this way, Ajax can be easily used to return multiple values.
4. Return the result to the page.
Document. getElementById ("txtCard_Money1"). value = arr [0];
5. Add the preceding Method to the Web. config file.
<HttpHandlers>
<Add verb = "POST, GET" path = "ajax/*. ashx" type = "Ajax. PageHandlerFactory, Ajax"/>
</HttpHandlers>
Today's content is written here, and I will write it later.
From: a wall that allows you to see shadows