JQuery + ajax Implementation of the brushless newest cascade menu example, jqueryajax
The front-end uses AJAX to directly call the back-end method. Some old people post and ask questions. There is nothing to do with an example.
The following is a front-end cascading menu that uses JQUERY and AJAX to call the background method.
CasMenu. aspx page:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "CasMenu. aspx. cs" Inherits = "_ Default" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
CasMenu. aspx. cs
Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; using CasMenuModels; using CasMenuBLL; using System. text; public partial class _ Default: System. web. UI. page {public static string strPro = string. empty; // province drop-down item public static string strCity = string. empty; // city drop-down protected void Page_Load (object sender, EventA Rgs e) {if (! IsPostBack) {} ShowPro ();} # region # province drop-down list box // <summary> // province drop-down list box // </summary> /// <returns> </returns> public string ShowPro () {StringBuilder str = new StringBuilder (); // obtain the List of all provinces <CasMenuModels. province> list = new CasMenuBLL. provinceManager (). getAllProvince (); // Add an initial str. append ("<option value = \" "); str. append ("0"); str. append ("\"> "); str. append ("= select ="); str. append ("</option>"); // cyclically Append the province drop-down item foreach (CasMenuModels. province p in list) {str. append ("<option value = \" "); str. append (p. provinceId); str. append ("\"> "); str. append (p. provinceName); str. append ("</option>");} return strPro = str. toString ();} # endregion # region # city drop-down list box /// <summary> // city drop-down list box /// </summary> /// <param name = "str"> Province ID </param> /// <returns> </returns> [System. web. services. webMethod ()] public static string ShowCity (string str) // The method is static {StringBuilder strCi = new StringBuilder (); if (str = "0 ") // For the initial entry {strCi. append ("<option value = \" "); strCi. append ("select"); strCi. append ("\"> "); strCi. append ("select"); strCi. append ("</option>");} else {List <CasMenuModels. city> list = new CasMenuBLL. cityManager (). getAllByProId (Convert. toInt32 (str); // obtain the City set foreach (City c in list) {strCi Based on the province ID. append ("<option value = \" "); strCi. append (c. cityId); strCi. append ("\"> "); strCi. append (c. cityName); strCi. append ("</option>") ;}return strCity = strCi. toString () ;}# endregion}
Note that I have comments,
Of course, the frontend transfer to the background method is far more than this method. For example, AJAXPRO is also very useful.
The above is all the content of this article. I hope you will like it.