Cascading Dropdown List VB error

Last post 12-04-2008 12:25 PM by khadeer_coleman. 23 replies.

Sort Posts:

  • Cascading Dropdown List VB error

    04-18-2006, 2:23 PM
    • Member
      160 point Member
    • Flugelboy2000
    • Member since 03-16-2004, 1:25 PM
    • St. Pete, FL
    • Posts 32

    I'm not a c# programmer but I'm trying to do straight conversion of the c# code to vb code for this page...

    http://atlas.asp.net/atlastoolkit/CascadingDropDown/CascadingDropDown.aspx

    ...and I'm getting an error on the "return" line that says...

    Value of type '1-dimensional array of AtlasControlToolkit.CascadingDropDownNameValue' cannot be converted to 'AtlasControlToolkit.CascadingDropDownNameValue'.

    Here is the original c# code...

     
    using System;
    using System.Web;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml;
    
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class CarsService : System.Web.Services.WebService
    {
        // Member variables
        private readonly XmlDocument _document;
        private readonly string[] _hierarchy;
    
        public CarsService()
        {
            // Read XML data from disk
            _document = new XmlDocument();
            _document.Load(Server.MapPath("CarsService.xml"));
    
            // Represent the hierarchy of data - "make" controls "model" (which implicitly controls "color")
            _hierarchy = new string[] { "make", "model" };
        }
    
        [WebMethod]
        public AtlasControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
        {
            // Get a dictionary of known category/value pairs
            StringDictionary knownCategoryValuesDictionary = AtlasControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
    
            // Perform a simple query against the data document
            return AtlasControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(_document, _hierarchy, knownCategoryValuesDictionary, category);
        }
    }

     

    And here is my vb code...

     

     
    Imports System.Web
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.Collections
    Imports System.Collections.Specialized
    Imports System.Xml
    Imports Microsoft.AtlasControlExtender
    Imports AtlasControlToolkit
    
    <WebService(Namespace:="http://tempuri.org/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Public Class CarsService
        Inherits System.Web.Services.WebService
        Dim document as New XmlDocument()
        Dim hierarchy as String()
    
        Public Sub CarsService()
            'Read XML data from disk
    
            document.Load(Server.MapPath("CarsService.xml"))
            hierarchy = New String() {"make", "model"}
        End Sub
    
        <WebMethod()> _
        Public Function GetDropDownContents(byVal knownCategoryValues as String, byVal category as String) as AtlasControlToolkit.CascadingDropDownNameValue
    
    
            Dim knownCategoryValuesDictionary as New StringDictionary 
            knownCategoryValuesDictionary = AtlasControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
    
            Return AtlasControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(document, hierarchy, knownCategoryValuesDictionary, category)
        End Function
     Is there anybody that might be able to help with this?  Thanks!
  • Re: Cascading Dropdown List VB error

    04-18-2006, 5:11 PM
    • Contributor
      4,198 point Contributor
    • Ted Glaza [MSFT]
    • Member since 04-12-2006, 11:51 PM
    • Microsoft
    • Posts 847
    • AspNetTeam

    Hi Flugelboy2000,

    You were very close - you just need to return an array of CascadingDropDownNameValue from the web service.  It should have a signature like this:

    Public Function GetDropDownContents(ByVal knownCategoryValues As String, ByVal category As String) As AtlasControlToolkit.CascadingDropDownNameValue()

    Thanks,
    Ted

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Cascading Dropdown List VB error

    04-19-2006, 9:44 AM
    • Member
      160 point Member
    • Flugelboy2000
    • Member since 03-16-2004, 1:25 PM
    • St. Pete, FL
    • Posts 32

    Oy!  It's always something so simple.

    Thanks for the reply!

  • Re: Cascading Dropdown List VB error

    05-05-2006, 4:01 PM
    • Member
      80 point Member
    • ostap100
    • Member since 05-05-2006, 5:37 PM
    • Posts 16

    Hi there,


    What if I have a web method with mutliple parameters. Let's say I would like to send not only value from category drop down but also Customer ID.

    How do I do that?

    Here is the task.

    There are 3 drop downs.

    1) Payment Type (Credit card or Pay Pal)
    2) Coupon that depends on Payment Method
    3) Price Points that depend on Payment Type and Coupon (it will include discounted prices)

    If you choose Payment Type Coupon drop down reloads. If you select Coupon Price Points drop down reloads. All of those values depend on Customer ID.

    Thank you,
    Aleksey

     

  • Re: Cascading Dropdown List VB error

    05-05-2006, 4:04 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    The sample doesn't support this scenario, but it doesn't seem like it would be too difficult to add just now. I'd think you could just add another parameter to your web service for the customer ID, and then modify the CascadingDropDown to retrieve that value (from a hidden field?) and pass it in with each web service call. Let us know if this works for you!

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Cascading Dropdown List VB error

    05-05-2006, 4:39 PM
    • Contributor
      4,198 point Contributor
    • Ted Glaza [MSFT]
    • Member since 04-12-2006, 11:51 PM
    • Microsoft
    • Posts 847
    • AspNetTeam

    Hi Aleksey,

    I think you have another option that would prevent you from having to tweak the JavaScript at all.  If you used "Page methods" instead of traditional web methods (see the cascading drop down sample from the new refresh), you should be able to access the Customer ID from the Page in the same way that you would do on a regular postback.

    Thanks,
    Ted

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Cascading Dropdown List VB error

    05-05-2006, 6:31 PM
    • Member
      80 point Member
    • ostap100
    • Member since 05-05-2006, 5:37 PM
    • Posts 16

    I just started playing with Atlas toolkit so I might not understand exactly what you mean.

    I guess one of the options (and i really don't like it) is to add pipe or comma separated values in a drop down and pass it as one parameter to the web service.
    Then parse it in web service and apply business logic there.

    Another option is to tweak control (since I have source code available).

    One thing I don't understand is why it is difficult to send mutliple parameters to the web service...
    Isn't it a common task?

    Thank you,
    Aleksey

  • Re: Cascading Dropdown List VB error

    05-05-2006, 7:05 PM
    • Contributor
      4,198 point Contributor
    • Ted Glaza [MSFT]
    • Member since 04-12-2006, 11:51 PM
    • Microsoft
    • Posts 847
    • AspNetTeam

    Hi Aleksey,

    One of the new features referred to as "Page methods" that Atlas allows is for you to use the [WebMethod] attribute on a method in your page and call it from the client like it was a webservice (http://atlas.asp.net/docs/atlas/doc/services/exposing.aspx#webpage).  So instead of calling directly into your webservice, you could call into your page which already has knowledge of the Customer ID.  Your page could either pass the request info and the Customer ID to the webservice, or you could just handle everything right there in the page.  I think for what you're describing this should work.

    In response to your other question about why you can't send multiple parameters - you can definitely call web services with multiple parameters using Atlas.  The cascading drop down, however, uses a very simple binding mechanism (just a path and a method name) which is what you don't like very much.  When designing most of the controls in the toolkit our philosophy was to make it very easy to implement the common scenario and avoid introducing a lot of complexity (because everyone has the source if they need to do anything really crazy).

    Thanks,
    Ted

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Cascading Dropdown List VB error

    05-05-2006, 9:48 PM
    • Member
      80 point Member
    • ostap100
    • Member since 05-05-2006, 5:37 PM
    • Posts 16

    Here what I did.

    I added Imports System.Web.Services to my ASPX page.

    I added web method to the page class

            <WebMethod()> _
            Public Function GetDropDownContents(ByVal knownCategoryValues As String, ByVal category As String, ByVal anotherparameter As String) As AtlasControlToolkit.CascadingDropDownNameValue()
                ' Read XML data from disk
    
                _document = New System.Xml.XmlDocument()
                _document.Load(Server.MapPath("~/App_Data/CarsService.xml"))
                ' Represent the hierarchy of data - "make" controls "model" (which implicitly controls "color")
    
                _hierarchy = New String() {"make", "model"}
    
                ' Get a dictionary of known category/value pairs
    
                Dim knownCategoryValuesDictionary As StringDictionary = AtlasControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
    
                ' Perform a simple query against the data document
    
                Return AtlasControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(_document, _hierarchy, knownCategoryValuesDictionary, category)
            End Function
    

    Added  aspx page reference to ServicePath property of CascadingDropDownProperties.

    No luck. It neither binds drop downs nor it throws any errors.

    Do you have any example of CascadingDropDown working with WebMethod of the ASPX page?

    Thank you,
    Aleksey

  • Re: Cascading Dropdown List VB error

    05-08-2006, 2:52 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842

    The CascadingDropDown sample in the update release (60504) has an example of calling an in-page Web Service.


    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Cascading Dropdown List VB error

    05-08-2006, 9:04 PM
    • Member
      80 point Member
    • ostap100
    • Member since 05-05-2006, 5:37 PM
    • Posts 16

    Yes but for some reason i can't get it to work with VB.

    I tried many things. If I change it so it uses main web service for every drop down it works. If I use Page Method it doesn't. What am I doing wrong?

    <

    atlasToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server">

    <atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList1" Category="Make" PromptText="Please select a make" ServiceMethod="OA.Web.GetDropDownContentsPageMethod" />

    <atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList2" Category="Model" PromptText="Please select a model" ServicePath="CSWeb.asmx" ServiceMethod="GetDropDownContents" ParentControlID="DropDownList1" />

    <atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList3" Category="Color" PromptText="Please select a color" ServicePath="~/WebServices/CSWeb.asmx" ServiceMethod="GetDropDownContents" ParentControlID="DropDownList2" />

    </atlasToolkit:CascadingDropDown>

    <WebMethod()> _

    Public Function GetDropDownContentsPageMethod(ByVal knownCategoryValues As String, ByVal category As String) As AtlasControlToolkit.CascadingDropDownNameValue()

    Dim ws As New OA.Web.WebServices.CSWeb

    Return ws.GetDropDownContents(knownCategoryValues, category)

    End Function
  • Re: Cascading Dropdown List VB error

    05-08-2006, 9:05 PM
    • Member
      80 point Member
    • ostap100
    • Member since 05-05-2006, 5:37 PM
    • Posts 16
    As you see I use Namespace for the page web method call. Well it doesn't work without it either.
  • Re: Cascading Dropdown List VB error

    05-09-2006, 1:45 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842

    To try this myself, I created a new page using VB (CDDVB.aspx) copied all the ASPX content from the sample's CascadingDropDown.aspx to the new file, and then filled in the VB implementation as you can see below. The VB page method appears to work fine for me. Hope this helps!

     
    Partial Class CascadingDropDown_CDDVB
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Label1.Text = "clicked"
        End Sub
    
        <System.Web.Services.WebMethod()> _
        Public Function GetDropDownContentsPageMethod(ByVal knownCategoryValues As String, ByVal category As String) As AtlasControlToolkit.CascadingDropDownNameValue()
            Return New CarsService().GetDropDownContents(knownCategoryValues, category)
        End Function
    End Class
    
     

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Cascading Dropdown List VB error

    05-17-2006, 7:23 AM
    • Member
      15 point Member
    • MJA1963
    • Member since 05-17-2006, 11:20 AM
    • Posts 3

    Hi

    I had the same problem calling the web method on an aspx page. I found a solution by removing the ServicePath and just having the name of the WebMethod in the ServiceMethod property

     

    <atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList3" Category="Color" PromptText="Please select a color" ServiceMethod="GetDropDownContents" ParentControlID="DropDownList2" />

     

    Hope this helps

  • Re: Cascading Dropdown List VB error

    06-08-2006, 10:03 AM
    • Member
      266 point Member
    • g-spot-web
    • Member since 01-10-2006, 9:26 AM
    • Posts 99
    Where can I obtain the CarsService.xml file?
Page 1 of 2 (24 items) 1 2 Next >