AJAX :: Cascading DropDownList - Method Error 500
Sep 24, 2013
I would like to populate Cascading DropDownList From SQL Server.
I prepare my project the same way as in this article: [URL] ....
But all the time I have "Method error 500" I read many articles how to solve this issue but without success.
Below there are my codes:
----SQL DB has two tables:
1.tblUAP (UAP (PK), Start_Date,End_Date)
2.tblGAP(idGAP (PK),GAP,UAP(FK to tblUAP))
---project1.aspx
<%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="Project1.aspx.cs" Inherits="TEST.Project1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
....
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
[Code].....
----Services.asmx
using System;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
[Code] ....
What else Can I check ??
View 1 Replies
Similar Messages:
Dec 6, 2010
I have a cascading dropdown which loads countries into a dropdownlist.
When I type: www.domain.com, it all works.
However, when I type: domain.com it stops working and the dropdown shows: "[method error -1]"
Here's my code:
<asp:TextBox ID="tbCity" Width="90" MaxLength="50" CssClass="inactive" autocomplete="off" runat="server" />
<cc1:AutoCompleteExtender ID="AutoSuggestCities" runat="server" TargetControlID="tbCity"
CompletionInterval="2" CompletionSetCount="50" MinimumPrefixLength="3" ContextKey="" ServicePath="http://www.domain.com/geolocation.asmx" ServiceMethod="GetCitiesForCountryOrProvince" />
ps. I use url rewriting and to make sure the servicepath is always correct I used the full path.
View 7 Replies
Jan 22, 2011
i hv been tryin since a long time..but not able to resolve my problem.M making a cascadin dropdown with ajax but gettin method error 500 in my dropdown on running it..here's my code1. dataservice.cs file
using System;
using System.Web;
using System.Collections;
[code]...
View 1 Replies
Jul 27, 2010
I have created a dropdown through code behind.Then created a Cascading dropdown that also through code behind.
All the properties of cascading dropdown have been initialized properly (as i think).
And web service method is defined in separate file.
DDL and Cascading DDL have been created in App_code/NewFolder through a class file. That webservice.vb file too is placed in this folder. and webservide.asmx file is placed in root directory of the project.
When i run the project dropdown is filled only with [Method error 500]. query to fetch data from database have been written in webservice.vb file without any known error.
View 3 Replies
Apr 16, 2010
I am getting [MethodError 500] when I use cascading drop down. below is my code
<tr>
<td >
Select a Hoster:
</td>
<td>
<asp:DropDownList ID="ddlFeaturedHoster" runat="server" ></asp:DropDownList>
</td>
</tr>
<ajaxToolkit:CascadingDropDown ID="cddHoster" runat="server" TargetControlID="ddlFeaturedHoster"
PromptText="Select a Hoster" LoadingText="Loading ..." Category="ActiveHoster"
ServiceMethod="GetDropDownContents" ServicePath="~/Hosting/HostingService.asmx"/>
Service Code:
[WebMethod]
[ScriptMethod]
public CascadingDropDownNameValue[] GetActiveHosters()
{
List<CascadingDropDownNameValue> returnList = new List<CascadingDropDownNameValue>();
HostersManager hosterManager = new HostersManager();
List<Hosters_HostingProviderDetail> hosters = hosterManager.GetAllHosters();
returnList.Add(new CascadingDropDownNameValue("--Please Select One--","0",true));
foreach (Hosters_HostingProviderDetail item in hosters)
{
returnList.Add(new CascadingDropDownNameValue() { name=item.HostingProviderName, value= item.HosterID.ToString()});
}
return returnList.ToArray() ;
}
[WebMethod]
[ScriptMethod]
public CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
{
knownCategoryValues = FormatCategoryWord(knownCategoryValues);
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
HostersManager hosterManager = new HostersManager();
switch (category)
{
case "ActiveHoster":
values.AddRange(GetActiveHosters());
break;
case "ActiveOffer":
values.AddRange(GetActiveOffers(1));
break;
}
return values.ToArray<CascadingDropDownNameValue>();
}
/// <summary>
/// Formats the category word
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
private string FormatCategoryWord(string value)
{
if (string.IsNullOrEmpty(value)) return value;
if (value.LastIndexOf(":") > 0) value = value.Substring(value.LastIndexOf(":") + 1);
if (value.LastIndexOf(";") > 0) value = value.Substring(0, value.LastIndexOf(";"));
return value;
}
}
View 2 Replies
Jan 31, 2011
I am trying to get my cascading comboboxes to work, but am getting a [Method error 500]. Any ideas? I've searched online, the code should work....Thanks in advance for your help!
ADDSTORY.ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="addstory.aspx.cs" Inherits="addstory" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<td class="style3">
<asp:DropDownList ID="selectproject" runat="server" Width="225"></asp:DropDownList>
<asp:CascadingDropDown ID="ccd1" runat="server"
ServicePath="~/dropdown.asmx?company=<%=co_id %>" ServiceMethod="GetProjects"
TargetControlID="selectproject" Category="Project"
PromptText="Select Project" />
</td>
</tr>
<tr>
<td class="style3"></td>
<td width = "150" class="style3">Iteration:</td>
<d class="style3">
<asp:DropDownList ID="selectiteration" runat="server" Width="225"></asp:DropDownList>
<asp:CascadingDropDown ID="ccd2" runat="server"
ServicePath="~/dropdown.asmx?company=<%=co_id %>" ServiceMethod="GetIterations"
TargetControlID="selectiteration" Category="Iteration"
PromptText="Select Iteration" />
</td>
</tr>
DROPDOWN.ASMX:
using System.Web.Script.Services;
using AjaxControlToolkit;
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.SqlClient;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "[URL]/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService()]
public class dropdown : System.Web.Services.WebService
{
private string GetConnectionString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
}
[WebMethod]
public CascadingDropDownNameValue[] GetProjects(string knownCategoryValues, string category)
{
string co_id = this.Context.Request.QueryString["company"].ToString();
SqlConnection conn = new SqlConnection(GetConnectionString());
sonn.Open();
SqlCommand comm = new SqlCommand("Select ProjectName, ProjectID FROM Project WHERE CompanyID = '" + co_id + "'", conn);
SqlDataReader dr = comm.ExecuteReader();
List<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
while (dr.Read())
{
l.Add(new CascadingDropDownNameValue(dr["ProjectName"].ToString(), dr["ProjectID"].ToString()));
}
conn.Close();
return l.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] GetIterations(string knownCategoryValues, string category)
{
int ProjectID;
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
if (!kv.ContainsKey("Project") || !Int32.TryParse(kv["Project"], out ProjectID))
{
throw new ArgumentException("Couldn't find project.");
};
SqlConnection conn = new SqlConnection(GetConnectionString());
conn.Open();
SqlCommand comm = new SqlCommand("SELECT Select CONVERT(VARCHAR(10), StartDate, 103) + ' - ' + CONVERT(VARCHAR(10), EndDate, 103) AS Iteration, ProjectIterationID FROM Iterations WHERE ProjectID=@ProjectID", conn);
comm.Parameters.AddWithValue("@ProjectID", ProjectID);
SqlDataReader dr = comm.ExecuteReader();
List<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
while (dr.Read())
{
l.Add(new CascadingDropDownNameValue(dr["Iteration"].ToString(), dr["ProjectIterationID"].ToString()));
}
conn.Close();
return l.ToArray();
}
}
View 1 Replies
Dec 21, 2013
Regarding this example: [URL] .... it works locally, within VS 2012.
But when I publish to a local or remote webserver, it doesn't show an error, but the dropdown lists are populated with this line: [Method Error: 500].
View 1 Replies
Oct 21, 2010
i'm using the Ajax cascading dropdown list it works fine. But how to call the server side after the dropdown list populated....
i don't want to call those method in drop down list index changed because it may cause postback..
View 6 Replies
Aug 31, 2013
I am referring to following line from this link [URL] ....
data 'continentId ' 'ddlContinents.ClientID'.val ''
In your code. i tried using this code and facing a tiny problem. In above mentioned code 'ddlContinents.ClientID'.val stores integer value in contentId for obvious reasons but the requirement of my code is different. i want to pass text which is selected instead of id no.for example if mumbai is listed as second option and i select mumbai it should store mumbai in contentId instead of 2 i.e. integer value.
View 1 Replies
Mar 2, 2011
I am trying to get two cascading dropdownlist to work but cannot get either to populate. How do I de-bug this? I'm not getting any errors, just blank dropdowns.
I've been trying to fill in webservice from SQL Server. But in-case this was the problem. I found an example on this site to fill with test values, but this still does not work. Since I cannot even get first to populate, to simplify I'm just giving code for first dropdown and its function(s)
[code]....
View 6 Replies
Jan 20, 2011
I am trying to select some data with dropdown lists which are related.
I select one of selection in dropdownlist1. After that, when my page reloads, dropdownlist2 is filled with table name which i am trying to get data from. (TBLYETKILI)
My code is below..
For dropdownlist1:
[Code]....
For dropdownlist2:
[Code]....
Also I am calling these functions as follows:
[Code]....
View 2 Replies
May 20, 2010
I think this needs to be a sticky since this is not solved anywhere that I have been looking... I have been googling this for a while now and came across the answer by shear luck and a simple typo when I was writing the code...
Problem: I have 2 dropdown lists...
ddllist1 and ddlist2... Both are code-behind populated via a sql DB.
they are cascading lists via the ajax control.
I am trying to dynamically populate them with values from a DB for edit reasons.
When I try to get them populated I kept getting the error...
"dropdownlist has a SelectedValue which is invalid because it does not exist in the list of items"
Solution:
1) get the values from the DB or from where ever...
2) create a sql select to get the values from the ddl db
3) set the ID of the first DDL control to cddcontrol1.SelectedValue = id (this is a number)
4) set the value of the DDL to the string value ddlist2.SelectedValue = value (this is a string)
here is the code.
[Code]....
View 1 Replies
Apr 12, 2010
I am dealing with a problem that i have to make decision based on the number of items in a cascading dropdownlist. unfortunately this ajax toolkit control does not expose a Items collection.how do i count the number of items in this control ?
View 1 Replies
Jun 10, 2010
I'm wanting to maintain the dropdownlist values that were selected when i use postbackurl with a button. They cascading dropdowns are on a masterpage in an accordion pane. I select the 3 vales in the ddl and then presss a button which redirects to the new content page.
I've been able to get the values using previousPage.master.fincontrol... but am then setting the selectedValue in the page_init of the conent page, but they aren't set when the page loads... does anyone know where to put the code to set the values?
View 2 Replies
Nov 12, 2010
Now i'm working on the cascading dropdownlist for to bind a country and city, city is based on country dropdownlist. its working well , if city comes more than 8000 records in city dropdownlist , takes more to bind city.
View 1 Replies
Sep 4, 2010
I really have no idea on this problem on the cascading dropdownlist. I have a cascading dropdownlist that bind with calling the web services.
I wan to do a autopostback to get the value of the Album GUId so that i can query out all the photo list of that album. it is working well if my page without the AlbumGUId query string.
my problem is:
when i redirect from other page and passing the Album GUId querystring to this page, it will display all my photo for this album guid. but when i change the album to Select which should be able to display all the Photos, it cannot display out. It only will work is when i choose another album and then go back to Select then it only can work..
[code]....
View 2 Replies
Mar 21, 2011
I'd like to set the selected value of cascading dropdownlist by reading from a Textbox.Text value when the dropdownlist has been populated, is this possible?
View 3 Replies
Jun 16, 2010
at last project i need to deploy cascading dropdownlist without using web serive or cascadingDropDownList Extender
i try to do this using updatepanel :D this work , but at many times that apear my computer and my internet Explorer as busy and hang and i can not do any thing untill populate the second dropdownlist :(
is there any way to avoid that and to view a wait message until populate the second dropdownlist , i mean is there a sample code for doing that
here is my code
[Code]....
View 1 Replies
May 7, 2015
I have two dropdownlist in cascading working, in my file file.aspx, all work good.the selected values from cascading dropdownlist bind my repeater. when select item inside repeater redirect me to second.aspx. when comeback to first.aspx i lose all selected values in cascading dropddowlist and also values in repeater.
View 1 Replies
Jan 2, 2010
i can populate cascading dropdownlist by using webservice now. but may i know how do i trigger function while selectedindex changed? (without using auto postback...)
View 3 Replies
Feb 26, 2010
I want to add items to a dropdownlist with values return by a webservice which will be called from javascript without cascading extender...
View 3 Replies
May 7, 2015
I have 3 Dropdownlist
1-DDlcity 2-DDlRegion 3-DDlDistrict
and below is House_info table
district region city Id can
1 Canada
1 Lon
1 London
2 Ita
2 Canada
3
Now when I select city from DDlcity after that select region from DDlregion according to my selected item from DDlcity and DDlregion it bind DDlDistrict... before I used OnselectedIndexChange below is SP...
ALTER procedure [dbo].[SelectِDistrict]
@Region NVARCHAR(30),
@city NVARCHAR(40)
[Code] ....
It worked correctly but now I use cascadingdropdown list
[WebMethod]
public CascadingDropDownNameValue[] GetDistrict(string knownCategoryValues)
{
string region = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)["Region"];
string query = string.Format("SELECT District FROM District WHERE Region = N'{0}'", region);
[Code] ....
problem is that when I select city=canada then region=1 I want it bind in DDldistrict =can but here it show in DDLdistrict can and Lon
here it just select district that region=1 it doesn't attention to city selected Item I want it do like SP that I used...
View 1 Replies
Aug 24, 2010
I wan to do a required field validation for the cascading dropdownlist . When my page first load out the validator is fired first in the google chrome, the callout extender message is prompt out first in the Google Chrome. I have tested the code in IE and safari, this two browsers never prompt out the validator callout first when the page is loaded.
i wonder why the google chrome will prompt out the validator when i validate the cascading dropdownlist. I have did some research on it, but failed to get any solution.
View 2 Replies
Sep 10, 2010
Have spent hours trying to create a Dynamic Data Field Template holding a DropDownList which is extended by the AJAX Cascading DropDown extension.Final form holds multiple cascading dropdown boxes. User selects Country (Land) then Postcodes, Counties (Provincie) are populated. Once postcode is selected then towns (Plaats) are populated. The problem I am now facing is that the viewstate for the dropdown lists is not being saved/restored after an insert action or custom validation error. So basically the dropdown lists are being reset to their default values.Some code (if missing parts, just ask and I will post them) - Don't mind the code structures etc... needs some refactoring :)Attribute I created:
[Code]....
KlantMetaData (=> Klant is Dutch for Customer ):
[Code]....
DynamicDropDownList Control I created:
[Code]....
Dynamic FieldTemplate created for inserts:
[Code]....
EntityTemplate I created:
[Code]....
Webservice methods created:
[Code]....
Code in masterpage:
[Code]....
View 1 Replies
Aug 6, 2010
I have a web app with several groups of cascading dropdownlists. All the cascading dropdownlists work as designed, but now the app is in the live enviroment with multiple users they are getting error 500 messages returned in some of the dropdownlists. Just wondered if there is a set amount of time to populate between selections? As these users are sometimes waiting tens of mins betwen selecting the values.On some of the dropdowns i'm pasing a date to the method using session variable whether this could be the issue? an example of one of the methods is below:
[Code]....
View 1 Replies