Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Using CascadingDropDown in a moduleUsing CascadingDropDown in a module
Previous
 
Next
New Post
7/21/2009 8:26 AM
 

Hello everyone,

I'm trying to use a CascadingDropDown in a module, but I have some problems. In a separate test project, all works fine, but when I try to use the same code in a module, the function GetDropDownContents written in the WebService never fires.

Can anyone suggest me a solution?

This is the sample code:

In Control.ascx:

<div >
        <div >CascadingDropDown Demonstration</div>
        <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>
        <br />
       
        <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
            Category="Make"  PromptText="Please select a make"  LoadingText="[Loading makes...]"
            ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" />
        <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2"
            Category="Model" PromptText="Please select a model" LoadingText="[Loading models...]"
            ServiceMethod="GetDropDownContentsPageMethod" ParentControlID="DropDownList1" />
        <cc1:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DropDownList3"
            Category="Color" PromptText="Please select a color" LoadingText="[Loading colors...]"
            ServicePath="CarsService.asmx" ServiceMethod="CarsService.GetDropDownContents"
            ParentControlID="DropDownList2" />
     
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="inline">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="[No response provided yet]" />
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="DropDownList3" EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
    </div>

 

 

In Control.ascx.vb

   <WebMethod()> _
        <System.Web.Script.Services.ScriptMethod()> _
        Public Shared Function GetDropDownContentsPageMethod(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
            Return New CarsService().GetDropDownContents(knownCategoryValues, category)
        End Function

 

In CarsService.asmx (the service file)

%@ WebService
    Language="VB"
    CodeBehind="~/App_Code/CarsService.vb"
    Class="CarsService" %>

in CarsService.vb (the code-behind service file)

' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License.
' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
' All other rights reserved.


Imports System
Imports System.Collections.Specialized
Imports System.Text.RegularExpressions
Imports System.Web
Imports System.Web.Services
Imports System.Xml

''' <summary>
''' Helper web service for CascadingDropDown sample
''' </summary>
<WebService([Namespace] := "http://tempuri.org/")> _
<WebServiceBinding(ConformsTo := WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
Public Class CarsService
    Inherits WebService
    ' Member variables
    Private Shared _document As XmlDocument
    Private Shared _inputValidationRegex As Regex
    Private Shared _lock As New Object()
   
    ' we make these public statics just so we can call them from externally for the
    ' page method call
    Public Shared ReadOnly Property Document() As XmlDocument
        Get
            SyncLock _lock
                If _document Is Nothing Then
                    ' Read XML data from disk
                    _document = New XmlDocument()
                    _document.Load(HttpContext.Current.Server.MapPath("~/App_Data/CarsService.xml"))
                End If
            End SyncLock
            Return _document
        End Get
    End Property
   
    Public Shared ReadOnly Property Hierarchy() As String()
        Get
            Return New String() {"make", "model"}
        End Get
    End Property
   
    Public Shared ReadOnly Property InputValidationRegex() As Regex
        Get
            SyncLock _lock
                If _inputValidationRegex Is Nothing Then
                    _inputValidationRegex = New Regex("^[0-9a-zA-Z \(\)]*$")
                End If
            End SyncLock
            Return _inputValidationRegex
        End Get
    End Property
   
    ''' <summary>
    ''' Helper web service method
    ''' </summary>
    ''' <param name="knownCategoryValues">private storage format string</param>
    ''' <param name="category">category of DropDownList to populate</param>
    ''' <returns>list of content items</returns>
    <WebMethod()> _
    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, InputValidationRegex)
    End Function
End Class
 

thank you!

 
New Post
7/22/2009 11:13 AM
 

I have discovered that the cause is a problem with AjaxControlToolkit, infact also a simple FilteredTextBoxExtender does not work!!!

Any idea about this?

 
New Post
7/22/2009 11:40 AM
 

Damn!

I simply solved adding this to load function:

Try

                If DotNetNuke.Framework.AJAX.IsInstalled Then
                    DotNetNuke.Framework.AJAX.RegisterScriptManager()
                End If
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Using CascadingDropDown in a moduleUsing CascadingDropDown in a module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out