Ajax controls tookite: cascadingdropdownlist attention please

Source: Internet
Author: User
Note the following when using cascadingdropdownlist:
(1) You can only use this control through web service.
(2) The created web service is as follows: [System. Web. Script. Services. scriptservice]
[WebService (namespace =   " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
Public   Class Basictypes: system. Web. Services. WebService
{

PublicBasictypes ()
{

// Uncomment the following line if using designed components
// Initializecomponent ();
}
[Webmethod]
Public Ajaxcontroltoolkit. cascadingdropdownnamevalue []Getdropdowncontents( String Knowncategoryvalues, String Category)
{
Datatable dt = Getdatatable ( " Select * From basictype " );
List < Ajaxcontroltoolkit. cascadingdropdownnamevalue > Values =   New List < Ajaxcontroltoolkit. cascadingdropdownnamevalue > ();
Foreach (Datarow Dr In DT. Rows)
{
Values. Add ( New Ajaxcontroltoolkit. cascadingdropdownnamevalue (Dr [ " Type " ]. Tostring (), Dr [ " ID " ]. Tostring ()));
}
Return Values. toarray ();
}
}

Note red Code .
In the PAGE method of cascadingdropdownlist, that is, in the background code of the page using this control, the name of the (3) webmethod called in Web service must be the same as the webmethod set in the control. As shown in bold and purple: < Ajaxtoolkit: cascadingdropdown ID = "Ccddatatypeparents" Runat = "Server" Enabled = "True"
Servicemethod ="Getdropdownparents" Parentcontrolid = ""
Usecontextkey = "True" Servicepath = "Basictypes. asmx"
Targetcontrolid = "Ddldatatypeparents"
Category = "Datatypeparentsid" Prompttext = "Select parent type"  
Loadingtext = "Loading parent type" Selectedvalue = "" >
</ Ajaxtoolkit: cascadingdropdown >

(4) use pagemethod as follows: [Webmethod]
[System. Web. Script. Services. scriptmethod]
Public   Static Ajaxcontroltoolkit. cascadingdropdownnamevalue [] getdropdownparents ( String Knowncategoryvalues, String Category)
{
Return   New Basictypes (). getdropdownparents (knowncategoryvalues, category );
}

Be sure to add the purple code section. The system will generate the purple part by itself, but it is different, so you just need to replace the automatically generated part of the system (I have not tried to replace it, but it can work now ).

When Error 500 occurs, check the precautions mentioned above.

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.