Ajax Asynchronization is used in a project. The pageload event of An aspx page needs to be used to read background data. If there are many ajax functions, it is not advisable to write many pages, the Code is as follows: ajaxPage. aspx page code:
Protected void Page_Load (object sender, EventArgs e)
{
String Action = Xkzi. Common. RequestHelp. Q ("Action ");
Switch (Action)
{
Case "ChackPass ":
{
// Obtain the string of the passed Password
String Pass = Tools. GetMD5 (Request. QueryString ["Pass"]. ToString ());
// Obtain the ID of the current user
// String CurrentUserId = Session ["CurrentUserId"]. ToString ();
String CurrentUserId = CurrentPatient. Id. ToString ();
// Determine whether the passed user ID and Password Match
DataSet ds = new DataSet ();
If (Business. Patient. CheckPass (Convert. ToInt32 (CurrentUserId), Pass ))
{
Response. Write ("the old password is successfully verified ");
}
Else
{
Response. Write ("failed to verify the old password ");
}
Break;
}
Case "Display ":
{
// Receives characters from the url.
String DicTitle = Request. QueryString ["Dic_Title"]. ToString ();
// Decoding
DicTitle = System. Web. HttpUtility. UrlDecode (DicTitle, System. Text. Encoding. GetEncoding ("GB2312 "));
// Obtain the data source
DataSet ds = new DataSet ();
Ds = Business. Dictionary. GetList ("Dic_Title = '" + DicTitle + "'");
String a = ds. Tables [0]. Rows [0] ["Dic_Content"]. ToString ();
// Output the desired result
Response. Write (ds. Tables [0]. Rows [0] ["Dic_Content"]. ToString ());
Break;
}
}
}
This Code includes two ajax functions: one is the slide word search on the page, and the other is the password verification.
Make some minor modifications to the JS files of those two functions.
Xmlhttp. open ("GET", "AjaxPage. aspx? Action = Display & Dic_Title = "+ encodeURI (keys), true );
In fact, it is to add and pass a parameter, and then determine the value of the input Action on the ajaxPage. aspx page to determine which function to use.
Reprinted from: http://www.cnblogs.com/yuanweisen/archive/2008/12/03/1346993.html#1402950