Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AJAX Cascading Dropdown using XML Data

$
0
0

hi guys, my dropdownlist returned [Method Error 500]..  may i know what's wrong to my code? pls advise. TQ

You can download the XML Data file here: northwind.xml

HTML code for Cascading Dropdown Extender Control

<asp:ScriptManager ID="ScriptManager1" runat="server">  </asp:ScriptManager>  <table border="0" cellpadding="2" cellspacing="0" width="500">  <tr>  <td width="100">  <b>Select Category :</b></td>  <td>  <asp:DropDownList ID="drdCategory" runat="server">  </asp:DropDownList>  <cc1:CascadingDropDown  
                ID="CascadingDropDown1"  
                runat="server"  
                Category="category"  
                TargetControlID="drdCategory"  
                PromptText="[Select Category]"  
                ServicePath="~/webservices/cascadingwebservice.asmx"  
                ServiceMethod="GetDropDownContents">  </cc1:CascadingDropDown>  </td>  </tr>  <tr>  <td>  <b>Select Product :</b></td>  <td>  <asp:DropDownList ID="drdProduct" runat="server" AutoPostBack="True">  </asp:DropDownList>  <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server"  
                Category="product"  
                TargetControlID="drdProduct"  
                ParentControlID="drdCategory"  
                PromptText="[Select Product]"  
                LoadingText="Loading products..."  
                ServicePath="~/webservices/cascadingwebservice.asmx"  
                ServiceMethod="GetDropDownContents">  </cc1:CascadingDropDown>  </td>  </tr> </table>     


Web Service for CascadingDropdown Extender

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml<WebService(Namespace:="http://tempuri.org/")> _<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class cascadingwebservice
    Inherits System.Web.Services.WebService

    Private Shared _xmlDocument As XmlDocument
    Private documentHierarchy As String() = New String() {"category", "product"}<WebMethod()> _
    Public Function GetDropDownContents(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.CascadingDropDownNameValue()
        _xmlDocument = New XmlDocument()
        _xmlDocument.Load(HttpContext.Current.Server.MapPath("~/App_Data/northwind.xml"))
        Dim knownCategoryValuesDictionary As StringDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
        Return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(_xmlDocument, documentHierarchy, knownCategoryValuesDictionary, category)
    End Function

End Class

 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>