Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cascading DropDown - Method error 500 1

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
I am getting this error when trying to use the AJAX Cascading DropDown. I was told to add an attribute to my Web Service

Code:
<Microsoft.Web.Script.Services.ScriptService()>

For some reason when I type "Microsoft." my intellisense does not pull up Web as the next level. Am I missing something else?

Thanks.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
if you installed the AJAX v1.0 the Microsoft namespace doesn't exist. instead it's System.[etc]

note: you need to add this attribute to the Page declaration [tt]EnableEventValidation="false"[/tt]. this disables protection from XSS, but it's required for the CDD to work.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for the response. I really needed it.

Ok. I used the System.etc and put the EnableEventValidation in the Page declaration and still get the error 500 as a list item.

This is the code behind my Web Service. Anything jump out at ya?

Code:
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

Imports AjaxControlToolkit
Imports System.Data
Imports System.Data.SqlClient

<WebService(Namespace:="[URL unfurl="true"]http://tempuri.org/")>[/URL] _
<System.Web.Script.Services.ScriptService()> _
Public Class GetNames

    Inherits System.Web.Services.WebService


    <WebMethod()> _
    Public Function GetLNames( _
                        ByVal knownCategoryValues As String, _
                        ByVal category As String) As CascadingDropDownNameValue()

        Dim values As New _
           System.Collections.Generic.List( _
           Of AjaxControlToolkit.CascadingDropDownNameValue)

        Dim conn As New SqlConnection( _
           "Data Source=.\KVCSQL;Initial Catalog=CLIENT_KS;" & _
           "Integrated Security=True")
        Dim comm As New SqlCommand( _
           "SELECT DISTINCT LNAME FROM MASTERFILE", conn)
        conn.Open()

        Dim reader As SqlDataReader = comm.ExecuteReader
        While reader.Read
            values.Add(New CascadingDropDownNameValue(reader("FNAME"), reader("COUNTER")))
        End While
        conn.Close()

        Return values.ToArray
    End Function

    <WebMethod()> _
    Public Function GetFNames( _
                        ByVal knownCategoryValues As String, _
                        ByVal category As String) As CascadingDropDownNameValue()

        Dim values As New _
           System.Collections.Generic.List( _
           Of AjaxControlToolkit.CascadingDropDownNameValue)

        Dim conn As New SqlConnection( _
           "Data Source=.\KVCSQL;Initial Catalog=CLIENT_KS;" & _
           "Integrated Security=True")
        Dim comm As New SqlCommand( _
           "SELECT DISTINCT FNAME, CSNBR FROM MASTERFILE", conn)
        conn.Open()

        Dim reader As SqlDataReader = comm.ExecuteReader
        While reader.Read
            values.Add(New CascadingDropDownNameValue(reader("FNAME") & " " & reader("CSNBR"), reader("CSNBR")))
        End While
        conn.Close()

        Return values.ToArray
    End Function

End Class

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
one thing I notice with the CDD is that the sample website has the first list load via a static web method in the aspx (instead of code behind or webservice).

last time I looked everyone was having this problem. their solution was to create a static webmethod within the aspx server tags and called their webservice from this method.

from then on calling subsequent drop downs shouldn't be an issue.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Ok, I noticed some other goofiness with my app before I read this and changed some things.

I have a new problem as I have progressed.

First of all I have two dropdowns. One gets all customer last names in a table. This is done the reqular way on PageLoad.

Then the second one is to only show first names with that last name. I am having troubles understanding the knownCategoryValues parm and how to pass the value of the first dropdown to the second one. Here is my WebMethod. If I hardcode my SELECT statement to say WHERE LNAME = a certain name, I get stuff back for my first name.

Code:
  <WebMethod()> _
    Public Function GetFNames( _
                        ByVal knownCategoryValues As String, _
                        ByVal category As String) As CascadingDropDownNameValue()


        Dim values As New _
           System.Collections.Generic.List( _
           Of AjaxControlToolkit.CascadingDropDownNameValue)

        Dim conn As New SqlConnection( "Data Source=KVCSQL;Initial Catalog=Client_KS;Integrated Security=True")
        Dim comm As New SqlCommand("SELECT DISTINCT FNAME, CSNBR " _
                                    & "FROM MASTERFILE ORDER BY FNAME", conn)
        conn.Open()

        Dim reader As SqlDataReader = comm.ExecuteReader

        While reader.Read
            values.Add(New CascadingDropDownNameValue(reader("FNAME") & " " & reader("CSNBR"), reader("CSNBR")))
        End While

        conn.Close()

        Return values.ToArray
    End Function

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
P.S.: The System.Etc got me further along too. That really helped. That's worth a star alone.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top