All Ajax functions in a project are implemented on a single page.

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.