Hi All,
I have recently started to learn AJAX, as well as all web developing. I am trying to read a database using a web service to populate drop down lists. I have searched through hundreds of posts and tried everything I found. The most common fix I found was to add System.Web.Script.Services.ScriptService before my class and System.Web.Script.Services.ScriptMethod before my WebMethod. I've tried upping my maxjsonlength. But these haven't fixed my problem. My problem being that on my development machine the app works fine, but on my webserver I get the Method Error 500. It seems like it can't find the asmx file, because, to see if it would even return anything, I took out the database read and put in bogus output.
Could my server be missing some key element to run AJAX? I have installed the Extentions on it. Is there something I have to do to deploy or publish the app? I have been just copying over all the files in my project.
I tried to put a call to the webservice in a page level method like they did on the How do I: cascading .. video, but that didn't work. I received a "BC30002: Type WebService not defined" Error. So that brings me back to thinking the app can't find the asmx file.
Anyone have any ideas?! Thanks for the help!
asmx file code:
Imports System.WebImports System.Web.Services
Imports System.Web.Services.Protocols
Imports AjaxControlToolkit
Imports System.Collections.Generic
Imports System.Data<WebService(Namespace:="http://tempuri.org/")> _<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
PublicClass WebServiceInherits System.Web.Services.WebService<WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
PublicFunction GetCategory(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()Dim myListAsNew List(Of CascadingDropDownNameValue)
Dim adapterAsNew DataSet1TableAdapters.sp_GetCategory1TableAdaptermyList.Add(New CascadingDropDownNameValue("test","test"))
Return myList.ToArray'For Each dr As DataRow In adapter.GetCategory1
' myList.Add(New CascadingDropDownNameValue(dr("Category1").ToString, dr("Category1").ToString))
'Next
'Return myList.ToArray
EndFunctionEndClass
aspx file code:
<%@dotnet.itags.org.PageLanguage="VB"AutoEventWireup="true"CodeFile="Default.aspx.vb"Inherits="_Default"EnableEventValidation="false" %>
<%@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %> 'DO I REALLY NEED THIS LINE?
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title></head>
<body>
<formid="form1"runat="server">
<asp:ScriptManagerID="ScriptManager1"runat="server"/>
<br/>
<br/>
<div>
<asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:DropDownListID="DropDownList1"runat="server"Width="232px">
</asp:DropDownList><br/>
<br/>
<br/>
<cc1:CascadingDropDownID="CascadingDropDown1"runat="server"Category="cat1"LoadingText="Loading..."
PromptText="Select Category"ServiceMethod="GetCategory"ServicePath="WebService.asmx"
TargetControlID="DropDownList1">
</cc1:CascadingDropDown>
<br/>
<br/>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form></body>
</html>
Thanks Again!
Princess
Well, I figured it out. Turns out I had my folders in the wrong place. The way I was referencing the webservice, the App_Code file, App_Data, & Bin folders plus the web.config file have to be at the top level of your application folder.
Mystery Solved!
Thats nice..So mark the answer, so it will help for otheres.
No comments:
Post a Comment