I re-used the AjaxWebService module (http://dotnetnuke.adefwebserver.com/DotNetNuke/tabid/195/Default.aspx) with no luck - still get the Method error 500 . The code logistics now looks like this:
CallWebServiceMethods.js
// CallWebServiceMethods.js
// This function calls the Web service method
// passing simple type parameters and the
// callback function
function Add(a, b)
{
YourCompany.Modules.CascadingDropDown.CarService.Add(a, b,
SucceededCallback);
}
// This function calls the Web service method
// that returns an XmlDocument type.
function GetXmlDocument()
{
YourCompany.Modules.CascadingDropDown.CarService.GetXmlDocument(
SucceededCallbackWithContext, FailedCallback,
"XmlDocument")
}
// This function calls the Web service method
// passing simple type parameters and the
// callback function
function GetDropDownContents(a, b)
{
YourCompany.Modules.CascadingDropDown.CarService.GetDropDownContents(a, b,
SucceededCallback, FailedCallback, "XmlDocument");
}
// This is the callback function invoked if the Web service
// succeeded.
// It accepts the result object, the user context, and the
// calling method name as parameters.
function SucceededCallbackWithContext(result, userContext, methodName)
{
var output;
// Page element to display feedback.
var RsltElem = document.getElementById("ResultId");
var readResult;
if (userContext == "XmlDocument")
{
if (document.all)
readResult =
result.documentElement.firstChild.text;
else
// Firefox
readResult =
result.documentElement.firstChild.textContent;
RsltElem.innerHTML = "XmlDocument content: " + readResult;
}
}
// This is the callback function invoked if the Web service
// succeeded.
// It accepts the result object as a parameter.
function SucceededCallback(result, eventArgs)
{
// Page element to display feedback.
var RsltElem = document.getElementById("ResultId");
RsltElem.innerHTML = result;
}
// This is the callback function invoked if the Web service
// failed.
// It accepts the error object as a parameter.
function FailedCallback(error)
{
// Display the error.
var RsltElem = document.getElementById("ResultId");
RsltElem.innerHTML =
"Service Error: " + error.get_message();
}
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
CARSERVICE.ASMX
<%@ WebService Language="VB" Class="YourCompany.Modules.CascadingDropDown.CarService" %>
Imports System.Web
Imports System.Web.Services
Imports System.Xml
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Namespace YourCompany.Modules.CascadingDropDown
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ScriptService()> _
Public Class CarService
Inherits System.Web.Services.WebService
' Member variables
Private _document As XmlDocument
Private _lock As New Object()
'we make these public statics just so we can call them from externally for the
'page method call
Public ReadOnly Property Document() As XmlDocument
Get
If _document Is Nothing Then
_document = New XmlDocument()
_document.Load(HttpContext.Current.Server.MapPath("CarsService.xml"))
End If
Return _document
End Get
End Property
Public ReadOnly Property Hierarchy() As String()
Get
Return New String() {"make", "model"}
End Get
End Property
Private _xmlString As String = _
"<?xml version=""1.0"" encoding=""utf-8"" ?>" + _
" <message>" + _
" <content>" + _
" Welcome to the asynchronous communication layer world!" + _
" </content>" + _
" </message>"
' This method returns an XmlDocument type.
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Xml)> _
Public Function GetXmlDocument() As XmlDocument
Dim xmlDoc As New XmlDocument()
xmlDoc.LoadXml(_xmlString)
Return xmlDoc
End Function 'GetXmlDocument
' This method uses GET instead of POST.
' Its input parameters are sent by the
' client in the URL query string.
<WebMethod()> _
<ScriptMethod(UseHttpGet:=True)> _
Public Function EchoStringAndDate(ByVal dt As DateTime, _
ByVal s As String) As String
Return s + ":" + dt.ToString()
End Function 'EchoStringAndDate
<WebMethod()> _
Public Function GetServerTime() As String
Dim serverTime As String = _
String.Format("The current time is {0}.", DateTime.Now)
Return serverTime
End Function 'GetServerTime
<WebMethod()> _
Public Function Add(ByVal a As Integer, _
ByVal b As Integer) As String
Dim addition As Integer = a + b
Dim result As String = _
String.Format("The addition result is {0}.", addition.ToString())
Return result
End Function 'Add
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Xml, _
XmlSerializeString:=True)> _
Public Function GetString() As String
Return "Hello World"
End Function
<WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Function GetDropDownContents(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.CascadingDropDownNameValue()
'Get a dictionary of known category/value pairs
Dim knownCategoryValuesDictionary As StringDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
'Perform a simple query against the data document
Return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category)
End Function
End Class 'WebService
End Namespace
CARSERVICE.XML
<?xml version="1.0" encoding="utf-8" ?>
<CarsService>
<make name="Acura">
<model name="Integra">
<color name="Green" />
<color name="Sea Green" />
<color name="Pale Green" />
</model>
<model name="RL">
<color name="Red" />
<color name="Bright Red" />
</model>
<model name="TL">
<color name="Teal" />
<color name="Dark Teal" />
</model>
</make>
<make name="Audi" value="Audi (value)">
<model name="A4" value="A4 (value)">
<color name="Azure" value="Azure (value)" />
<color name="Light Azure" value="Light Azure (value)" />
<color name="Dark Azure" value="Dark Azure (value)" />
</model>
<model name="S4" value="S4 (value)">
<color name="Silver" value="Silver (value)" />
<color name="Metallic" value="Metallic (value)" />
</model>
<model name="A6" value="A6 (value)">
<color name="Cyan" value="Cyan (value)" />
</model>
</make>
<make name="BMW" value="BMW (value)">
<model name="3 series" value="3 series (value)">
<color name="Blue" value="Blue (value)" />
<color name="Sky Blue" value="Sky Blue (value)" />
<color name="Racing Blue" value="Racing Blue (value)" />
</model>
<model name="5 series" value="5 series (value)">
<color name="Yellow" value="Yellow (value)" />
<color name="Banana" value="Banana (value)" />
</model>
<model name="7 series" value="7 series (value)">
<color name="Brown" value="Brown (value)" />
</model>
</make>
</CarsService>
ViewCascadingDropDown.ascx
<%@ Control language="vb" Inherits="YourCompany.Modules.CascadingDropDown.ViewCascadingDropDown" CodeFile="ViewCascadingDropDown.ascx.vb" AutoEventWireup="true" Explicit="True" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<table>
<tr>
<td>Make</td>
<td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td>
</tr>
<tr>
<td>Model</td>
<td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td>
</tr>
<tr>
<td>Color</td>
<td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" AutoPostBack="true"
OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" /></td>
</tr>
</table>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
Category="Make" PromptText="Please select a make" LoadingText="[Loading makes...]"
ServiceMethod="GetDropDownContents" />
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2"
Category="Model" PromptText="Please select a model" LoadingText="[Loading models...]"
ServiceMethod="GetDropDownContents" ParentControlID="DropDownList1" />
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DropDownList3"
Category="Color" PromptText="Please select a color" LoadingText="[Loading colors...]"
ServiceMethod="GetDropDownContents"
ParentControlID="DropDownList2" />
<br />
<div>
<h2>
Calling Web Methods</h2>
<table>
<tr align="left">
<td>
Method that takes parameters:</td>
<td>
<!-- Passing simple parameter types to
the Web service. -->
<button id="Button3" onclick="Add(30, 30); return false;">
Add</button>
</td>
</tr>
<tr align="left">
<td>
Method that returns XML data:</td>
<td>
<!-- Get Xml. -->
<button id="Button4" onclick="GetXmlDocument(); return false;">
Get Xml</button>
</td>
</tr>
<tr align="left">
<td>
Method that returns XML data:</td>
<td>
<!-- Get Xml. -->
<button id="Button1" onclick="GetDropDownContents('','Make'); return false;">
Get Xml</button>
</td>
</tr>
</table>
</div>
<hr />
<div>
<span id="ResultId"></span>
</div>
ViewCascadingDropDown.ascx.VB
'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2006
' by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports DotNetNuke
Imports DotNetNuke.Security.Roles
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports System.Web
Namespace YourCompany.Modules.CascadingDropDown
''' -----------------------------------------------------------------------------
''' <summary>
''' The ViewDynamicModule class displays the content
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Partial Class ViewCascadingDropDown
Inherits DotNetNuke.Entities.Modules.PortalModuleBase
#Region "Private Members"
Private strTemplate As String
#End Region
#Region "Event Handlers"
''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
If Not Page.IsPostBack Then
' Determine if AJAX is installed
If DotNetNuke.Framework.AJAX.IsInstalled Then
DotNetNuke.Framework.AJAX.RegisterScriptManager()
' Create a reference to the Script Manager
Dim objScriptManager As ScriptManager = ScriptManager.GetCurrent(Me.Page)
' Add a reference to the web service
Dim objServiceReference As ServiceReference = New ServiceReference
objServiceReference.Path = "~/DesktopModules/CascadingDropDown/CarService.asmx"
objScriptManager.Services.Add(objServiceReference)
Dim objScriptReference As ScriptReference = New ScriptReference
objScriptReference.Path = "~/DesktopModules/CascadingDropDown/CallWebServiceMethods.js"
objScriptManager.Scripts.Add(objScriptReference)
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace