JQuery + ajax Implementation of the brushless newest cascade menu example, jqueryajax

Source: Internet
Author: User

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.

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.