Showing posts with label cascading. Show all posts
Showing posts with label cascading. Show all posts

Monday, March 26, 2012

Cascasding drop down - Error 500

Hi
I am playing with the cascading drop down control...
i have written a method to get data from sql 05 database and return andarray of CascadingDropDownNameValue. (i watched one of the how towebcasts on it)....anyway, i can get it to work else where but forsome reason its not working with this one.
I know the method is returning the right data as i have another methodwhich returns all values in a string[] i then dump on the screen andall is ok.
My CCD declaration.

<atlasT:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasT:CascadingDropDownProperties

Category="CategoryName"

ParentControlID="ddlClass"

TargetControlID="ddlCourses"

PromptText="All"ServiceMethod="GetCoursesByIdClass"

ServicePath="webservices/FillDropDowns.asmx"/>

</atlasT:CascadingDropDown>

My method...

[WebMethod]

publicCascadingDropDownNameValue[] GetCoursesByIdClass(string knownCategoryValues,string category)

{

// Get connection string from web.config

string dsn = System.Configuration.ConfigurationManager.ConnectionStrings["connCleo"].ConnectionString;

string[] categoryValues = knownCategoryValues.Split(':',';');

int idClass =Convert.ToInt32(categoryValues[1]);

// SQL script

string sql =@dotnet.itags.org."SELECT c.idCourse, c.chrName FROM cleo.Course c

JOIN cleo.CourseAssign ca ONca.idCourse=c.idCourse

WHERE idClass=@dotnet.itags.org.idClass

ORDER BY c.chrName";

// Generic list for collection

List<CascadingDropDownNameValue> cascadeCollection =newList<CascadingDropDownNameValue>();

// Open connection and execute command...loop through reader and add items to list.

using(SqlConnection conn =newSqlConnection(dsn))

using (SqlCommand cmd =newSqlCommand(sql, conn))

{

cmd.Parameters.AddWithValue("@dotnet.itags.org.idClass", idClass);

conn.Open();

using (SqlDataReader reader = cmd.ExecuteReader())

{

while (reader.Read())

{

cascadeCollection.Add(newCascadingDropDownNameValue(reader.GetString(1), reader[0].ToString()));

}

}

}

// return collection as an array.

return cascadeCollection.ToArray();

}


I dont know of anyway i can debugthis to see if i am infact getting the correct values back(not surewhat values i need to pass to the method to mimic the call from thetoolkit.)?

Hopefully someone can see where i am going wrong.??

Thanks
Steve

OK, so i am pulling my hair out and have no idea where to look for help other than here.

I have put the same code in another project and it works fine.

The only difference that i can see is the version of the Atlas and Toolkit dll.

The date stamp on the one that works is 04/05/2006
The one that doesnt work is 27/06/2006

So begs the question....what has changed in the June CTP that stops my service from working?

Any ideas?
Steve


Again...the brick wall.
I added in the new CTP dll's to my project that works and it still works.

If i add the old dll's into my not working project...i dont get error 500, but i do get a popup error when trying to change the selection of parent ddl...(eventvalidation error) and no, nothing is bound to the Drop down.

:-(

Steve


sorted it!!!!

I was missing stuff from the web.config file !!!

Well thats two hours of my life gone!!!

Steve


OK...new error now. i seem to be speaking to myself here but if anyone does join in maybe they can help.

The drop down is not binding fine...problem is when i try and postback (with button) i get a postback validation error (there are a few posts on here with no clear answer, none regarding the CDD control though)...anyway, so i turn of validation and the value in the second drop down list has nothing...it should be an number (as id for the text on display...nothing odd there).

I have tried

protectedoverridevoid Render(HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation(this.UniqueID);
base.Render(writer);
}

but this has no affect.

Steve


i was a touch hasty with my previous post...there is a value in the selectedvalue property....however i was checked that selectedindex > 0...even though it was, it wasnt (if that makes sense - the debugger says 0)...however i got round this withstring.IsNullOrEmpty(ddl.SelectedValue)

But now i have to have eventvalidation off.

What are the implications of this...surely this isnt correct? I must be able to have it turned on...not sure what i does but feel like i'm missing out!!!!!!

Anybody?

Steve


Seee http://forums.asp.net/thread/1293293.aspx #20

Event Validation just makes sure the values you posted from your dropdown are valid values you populated it with. But seeing as the cascading dropdown populates from script, this wont/cant work and if you need to, validate the values on the server (its a security thing)

cascadingdropdowns when only one listitem

I am happily using cascading dropdowns for a three-level stack. In some cases, there is only one item in the generated list apart from the select prompt. Common sense and good design suggests that the one item should be auto-selected but this has not been implemented in the Toolkit.

I tried to implement it by setting the selected attribute (third parameter) to 'true' in the Web service. This worked for the displayed ddl, but the underlying value was not set . Hence the next level in the dropdown failed because no value was supplied.

Is this a bug or am I doing something wrong?

The relevant line in the VB Web Service (PageMethod) is:

values.Add(

New CascadingDropDownNameValue(sCompany, sCompanyId,True))

If I do not use the third parameter, I get the standard result with my Prompt showing in the ddl, and everything working when I actually select the one item.

This sounds like a bug. Could you whip up a quick sample page demonstrating the problem and file the issue at CodePlex?

http://www.codeplex.com/WorkItem/List.aspx?ProjectName=AtlasControlToolkit

Thanks!

CascadingDropDowns Not Enabling

I'm just trying to get simple cascading drop down functionalityworking, and I'm having some issues with the second drop down gettingenabled once a selection has been made in the first drop down. I candebug and step through correctly, and everything seems like it shouldbe working, it's just that the control is never enabled.

I've checked this thread (http://forums.asp.net/thread/1278728.aspx), because it seemed similiar, and I've already set enabledEventValidation to false for the page. What am I missing?

Here what I've got:

<asp:DropDownList ID="dropdownlist" runat="server" />
<asp:DropDownList ID="dropdownlist1" runat="server" /
<atlasToolkit:CascadingDropDown ID="CascadingDropDowns" runat="server">
<atlasToolkit:CascadingDropDownPropertiesTargetControlID="dropdownlist" Category="Make" PromptText="Pleaseselect a value" ServicePath="dropdown.asmx" ServiceMethod="GetValues"/>
<atlasToolkit:CascadingDropDownPropertiesTargetControlID="dropdownlist1" ParentControlID="dropdownlist"Category="Model" PromptText="Please select a make" ServicePath="dropdown.asmx" ServiceMethod="GetValues" />
</atlasToolkit:CascadingDropDown
And then, my Web Service:

<%@dotnet.itags.org. WebService Language="VB" Class="dropdown" %
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://k299/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class dropdown
Inherits System.Web.Services.WebService

Public Function dropdown()
Return Nothing
End Function

<WebMethod()> _
Public Function GetValues(ByVal knownCategoryValues As String, ByValcategory As String) As AtlasControlToolkit.CascadingDropDownNameValue()
Dim cddvArray(1) As AtlasControlToolkit.CascadingDropDownNameValue
Dim strDisplay As String = ""
If category = "Make" Then
strDisplay = "Michigan"
Else
strDisplay = "Missouri"
End If
Dim cddv1 As New AtlasControlToolkit.CascadingDropDownNameValue(strDisplay, "MO")
cddvArray(0) = cddv1
Return cddvArray
End Function

End Class

You're creating a 2-element array and filling in only one of the two elements, leaving the other empty. Change the first line of GetValues to the following and your sample works fine for me:

Dim cddvArray(0) As AtlasControlToolkit.CascadingDropDownNameValue


And to think, I was pulling my hair out on something that simple. I knew I should have gotten more sleep :)

Thanks!

Saturday, March 24, 2012

CascadingDropDownList - Adding KnownCategoryValues through code

I am using several Cascading Drop Down Lists.

Is there a way that I can add values to the knownCategoryValues and category parameters that get passed to the webmethods?

For example:

[

WebMethod(EnableSession =true)]
publicCascadingDropDownNameValue[] GetSkill(
string knownCategoryValues,
string category)
{
int SubSystem_ID =int.Parse(Session["PageSubSystem"].ToString());
StringDictionary kv =CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

int Location_ID;
if (!kv.ContainsKey("Location") || !int.TryParse(kv["Location"],out Location_ID))
{
returnnull;
}

Sorry for the badly formatted code, but the Code Entry thing is not working.

Anyway, how would I add a "Key" of Location to the parameters? Would this have to be in the WebService, or can I add it from the web page?

Any help on this would be greatly appreciated!

Try to take a look at the following link about how to useAjax:CascadingDropDown with a Database for reference.
http://ajax.alpascual.com/Walkthrough/CCDWithDB.aspx
Wish this can help you.

CascadingDropDown, SelectedValue in a bound form

Hey folks,

I don't know if it's been addressed, but I couldn't find the solution.

I need to databind selectedValue of a cascading dropdown. Since TargetProperties cannot be databound using <#% #> syntax, I use DataBinding event handler:

 <form id="form1" runat="server"> <div> <atlas:ScriptManager ID="scriptManager" runat="server" EnablePartialRendering="true" /> <asp:FormView ID="frm1" runat="server" DefaultMode="insert"> <InsertItemTemplate> <asp:Button ID="btnToggle" runat="server" OnClick="btnToggle_OnClick" Text="Toggle dropdown panel" /> <asp:Panel ID="pnlDropdown" runat="server" Visible="false"> <asp:DropDownList ID="ddl1" runat="server" /> <atlasToolkit:CascadingDropDown runat="server" ID="cdd1" OnDataBinding="cdd1_DataBinding"> <atlasToolkit:CascadingDropDownProperties TargetControlID="ddl1" ServiceMethod="GetOptions" PromptText="--Select--" Category="Options" /> </atlasToolkit:CascadingDropDown> </asp:Panel> </InsertItemTemplate> </asp:FormView> </div> </form>

With the following codebehind:

protected void btnToggle_OnClick(object sender, EventArgs args) { Panel pnlDropdown = (Panel) ((Control)sender).Parent.FindControl("pnlDropdown" ); pnlDropdown.Visible = !pnlDropdown.Visible; }protected void cdd1_DataBinding(object sender, EventArgs args) { CascadingDropDown cdd1 = (CascadingDropDown)sender; cdd1.TargetProperties[0].SelectedValue ="1"; } [WebMethod]public CascadingDropDownNameValue[] GetOptions(string knownCategoryValues,string category) { CascadingDropDownNameValue[] cddValues =new CascadingDropDownNameValue[] {new CascadingDropDownNameValue("one","1"),new CascadingDropDownNameValue("two","2") };return cddValues; }

The problem exhibits itself only if the CascadingDropDown is originally hidden.

Obviously, this isn't the production code, but it models the behaviour precisly.

Any way to solve it?

Thanks in advance,

ET

Sorry, I forgot to state the actual problem, thespecified SelectedValue is ignored if the dropdown is not visible at the time of binding. Why?

et_td:

Hey folks,

I don't know if it's been addressed, but I couldn't find the solution.

I need to databind selectedValue of a cascading dropdown. Since TargetProperties cannot be databound using <#% #> syntax, I use DataBinding event handler:

 <form id="form1" runat="server"> <div> <atlas:ScriptManager ID="scriptManager" runat="server" EnablePartialRendering="true" /> <asp:FormView ID="frm1" runat="server" DefaultMode="insert"> <InsertItemTemplate> <asp:Button ID="btnToggle" runat="server" OnClick="btnToggle_OnClick" Text="Toggle dropdown panel" /> <asp:Panel ID="pnlDropdown" runat="server" Visible="false"> <asp:DropDownList ID="ddl1" runat="server" /> <atlasToolkit:CascadingDropDown runat="server" ID="cdd1" OnDataBinding="cdd1_DataBinding"> <atlasToolkit:CascadingDropDownProperties TargetControlID="ddl1" ServiceMethod="GetOptions" PromptText="--Select--" Category="Options" /> </atlasToolkit:CascadingDropDown> </asp:Panel> </InsertItemTemplate> </asp:FormView> </div> </form>

With the following codebehind:

protected void btnToggle_OnClick(object sender, EventArgs args) { Panel pnlDropdown = (Panel) ((Control)sender).Parent.FindControl("pnlDropdown" ); pnlDropdown.Visible = !pnlDropdown.Visible; }protected void cdd1_DataBinding(object sender, EventArgs args) { CascadingDropDown cdd1 = (CascadingDropDown)sender; cdd1.TargetProperties[0].SelectedValue ="1"; } [WebMethod]public CascadingDropDownNameValue[] GetOptions(string knownCategoryValues,string category) { CascadingDropDownNameValue[] cddValues =new CascadingDropDownNameValue[] {new CascadingDropDownNameValue("one","1"),new CascadingDropDownNameValue("two","2") };return cddValues; }

The problem exhibits itself only if the CascadingDropDown is originally hidden.

Obviously, this isn't the production code, but it models the behaviour precisly.

Any way to solve it?

Thanks in advance,

ET


As a workaround, I found that setting SelectedValue in an FormView.ItemCreated event handler works.

Cheers,

ET

CascadingDropDown works locally but not in production :(

I have a webcontrol that has a cascading drop down on it. It works great locally and it even works on one site on the production box but on another site it's not working at all.

When i view the soure locally, the bottom of the page has this:


<script type="text/javascript">
<!--
Sys.Application.queueScriptReference('/ScriptResource.axd?d=l8kme79LK37kNlRrAwkn4PmL8-xStSVBSrJo-1R7TM1iwaoCqJ1vwb4J4WezGvqzcUVV2DXtyW0_vdYX2osULzIIpv4c1X8ugso_D_opuH_NgNvFbZCQpZuDNYA5QZiu0&t=632999597834800200');
Sys.Application.queueScriptReference('/ScriptResource.axd?d=l8kme79LK37kNlRrAwkn4PmL8-xStSVBSrJo-1R7TM1iwaoCqJ1vwb4J4WezGvqzcUVV2DXtyW0_vdYX2osULzJI-iPrGdhwBb_ttd4JLeZNXWsInBtmjFBOo2HjJO4T0&t=632999597834800200');
Sys.Application.queueScriptReference('/ScriptResource.axd?d=l8kme79LK37kNlRrAwkn4PmL8-xStSVBSrJo-1R7TM1iwaoCqJ1vwb4J4WezGvqzcUVV2DXtyW0_vdYX2osULxwEztykssfzEPaqC7e0w3GSj3I_ajLJJSZPUOiWBO-4WX5KGuOIsKnZ6bBD0-vgFw2&t=632999597834800200');
Sys.Application.queueScriptReference('/ScriptResource.axd?d=l8kme79LK37kNlRrAwkn4PmL8-xStSVBSrJo-1R7TM1iwaoCqJ1vwb4J4WezGvqzcUVV2DXtyW0_vdYX2osUL8XSATuKv5sfFg9o9Zcf0duyde9-TL64IHjvO6rQEiff0xK_M6hS6brl95FcYskfAIaBT0vTReXwWC6ZPyjzBVA1&t=632999597834800200');
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.CascadingDropDownBehavior, [SNIP]);
});
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.CascadingDropDownBehavior, [SNIP]);
});
Sys.Application.initialize();
// -->
</script>
 
but when i view the source from production, that's completely missing. Anyone run into something like this before? 
 
BTW: this is on beta 2 and v.1.0.61106.0 of the toolkit. 

I was able to solve this myself by digging deeper.

there was a multiview on the page and the scriptmanager was in one of the views but not the others so no errors were thrown but the scriptmanager wasn't rendering the javascript.

CascadingDropDown with two items containing the same value

I'd like to create a cascading drop down control with two list items that have the same value and also be able to programmatically populate the drop down via the selected item's text. I haven't seen anything like this and I can't see a way to do it.

In the sample pages I've changed the CarService.xml file as follows:

1 <make name="Audi" value="Audi (value)">2 <model name="A4" value="A4 (value)">3 <color name="Azure" value="Azure (value)" />4 <color name="Light Azure" value="Light Azure (value)" />5 <color name="Dark Azure" value="Dark Azure (value)" />6 <color name="Test Azure" value="Dark Azure (value)" />7 </model>

...adding the "Test Azure" color node with the same value as "Dark Azure". Note that when you select "Dark Azure" on the page, then select "Test Azure", theDropDownList3_SelectedIndexChanged event doesn't fire.

Does anyone know how to do this?

Hi,

I tried it, it worked fine.

I add the line

<color name="Test Azure" value="Dark Azure (value)" /> to the xml file as you described, and didn't modify a line of code.
 

I tried it again and still no dice. It may not be possible:

I created the following page to test regular asp.net...

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void ddlTest_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = String.Format("{0} - {1}", ddlTest.SelectedIndex, ddlTest.SelectedValue); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="ddlTest" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlTest_SelectedIndexChanged"> <asp:ListItem Text="Apple" Value="Red"></asp:ListItem> <asp:ListItem Text="Banana" Value="Yellow"></asp:ListItem> <asp:ListItem Text="Apple Again" Value="Red"></asp:ListItem> </asp:DropDownList> <asp:Label ID="Label1" runat="server"></asp:Label> </div> </form></body></html>

Notice that selecting "Apple Again" will autopostback with "Apple" selected. I'll look for another solution.


That's because "apple" and "apple again" have the same value.

CascadingDropDown slow to load in IE7?

I have a cascading dropdown that loads about 13,000 items from a PageMethod. In Firefox 2 this takes just under 5 seconds, but the same page in IE7 is taking about 160 seconds to load the same dropdown! IE response to using that page is also slow once it has loaded.

If I populate the dropdown server-side by binding a datasource directly to the control is takes a while to render the page but nowhere near 2.5 minutes.

Code example:

HTML:

<asp:dropdownlist id="ddlAlert" runat="server" width="100%"></asp:dropdownlist>
<ajt:CascadingDropDown ID="cddAlerts" runat="server" TargetControlID="ddlAlert" Category="Alert" ServiceMethod="GetAlerts" LoadingText="Loading alerts..." />
Code Behind:
 <System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetAlerts(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()
Dim retValAs New Collections.Generic.List(Of CascadingDropDownNameValue)
retVal.Add(New CascadingDropDownNameValue("All Alerts","0",True))
Dim appAs New MOAE.MOAE
Dim dsAs DataSet = app.GetAlertProfiles
Try
For Each rowAs DataRowIn ds.Tables(0).Rows
retVal.Add(New CascadingDropDownNameValue(row("AlertDisplayName").ToString, row("AlertProfileID").ToString))
Next
Catch exAs Exception
app.LogWarning(ex, Diagnostics.EventLogEntryType.Error)
End Try ds =Nothing app =Nothing
Return retVal.ToArray
End Function

Does anyone have any way of speeding this up? Is this just down to IE's Javascript engine?

Cheers,
Nick

I know this isn't the answer you want to hear, but as a user I would cringe at a dropdown containing 13k items. How would I ever find the item I'm looking for. Isn't there a better design implementation?

I don't know but I could certainly see IE having a heart attack with a 13k dropdown and that would account for the slow page. Might not be completely fixable if that's the case...


It's the conclusion I had come to as well but I was curious at the disparity in speed between Firefox's and IE's implementation of this....


Hi Nickfoster,

IE7 and Firefox are have their own merits. Some tests show that Firefox do better job on string processing. But I am quite agree with Noahb, we should limit its items in your case.

Best regards,

Jonathan

Wednesday, March 21, 2012

CascadingDropDown placed inside an asp:EditItemTemplate.

I tried the cascading dropdownlist when the user clicks on edit on a formview, but I realized from the following error that this will not work:

System.InvalidOperationException: The UpdatePanel 'EditUpdatePanel' was not present when the page's InitComplete event was raised. This is usually caused when an UpdatePanel is placed inside a template.

I also found a previous threadhttp://forums.asp.net/thread/1255759.aspxwhere the respondent confirmed that the updatePanel must be outside of the GridView

Does that mean that theAtlasControlToolkit:cascadingdropdown control cannot be used within any databound templated controls (such as GridView, FormView, Details, etc.)?

I don't believe so. UpdatePanel has "special needs" on the page which is why it probably has this issue. I haven't tried this but I think CascadingDropdownshould work OK - I can't think of why it wouldn't. Can you give it a try and report back?


I think the problem is that theatlasToolkit:CascadingDropDown requires anatlas:UpdatePanel around the dropdownlists otherwise changing the selection in one dropdownlist would not affect the next. But sinceatlas:UpdatePanel cannot be placed within the EditItemTemplate therefore it seems that there is no way to put theatlasToolkit:CascadingDropDown within the EditItemTemplate.

Here I tried 3 scenarios in addition to the one I described in my previous post:

1- The cascadingdropdown lists work if placed within atlas:UpdatePanel outside of an EditItemTemplate:http://www.webswapp.com/codesamples/aspnet20/atlas/cascadingdropdown.aspx

2- The cascadingdropdown lists not working if placed within the EditItemTemplate and the atlas:UpdatePanel outside the FormView. http://www.webswapp.com/codesamples/aspnet20/atlas/cascadingdropdown2.aspx

(On my local PC, a JavaScript popup dialog box comes with the following error: "System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using in configuration or in a page." But when run remotely you do not get that error. The lists just do not display anything)

3- The cascadingdropdown lists not working if placed within the EditItemTemplate and no atlas:UpdatePanel on the page

The source code for all scenario are listed on the demo pages.


CascadingDropDown does not need an UpdatePanel to work - the client-side changes are done in script and the web service requests are async thanks to Atlas. So #3 above is the scerario you probably want. I suspect it's not working for you because your ParentControlID properties are pointing at "CascadingDropDownX", but your DropDown controls are named "ddlYYY". Please try fixing that and let us know how it goes!

Hi David,

Thanks for your help. Your suspicion was right. I had the wrong values for the ParentControlID. Now that I corrected them and got it working within the FormView's EditItemTemplate and the data is being updated upon postback successfuly as shown here: http://www.webswapp.com/codesamples/aspnet20/atlas/toolkit_cascadingdropdown.aspx

I am wondering about the possibility of doing 2 more features to make the function of this control equivalent to the server-side controls:

1- How to set the default values upon loading the EditItemTemplate? (Since I could not use the Bind or Eval statements)

2- In order to prevent flashing of the screen when I submit the FormView, I tried using the Atlas:UpdatePanel around the FormView but I got this error message:

Assertion Failed: Unrecognized tag AtlasControlExtender:ValidationScript


That is so cool!

From above...

1) This is a feature we've added to the refresh, which should be available within the next day or so. When it is, you can just add a "SelectedValue='blah'" to the properties and it'll select that value

2) I'm not sure why you're getting that. In any case, in your extender set "SuppressValidationScript='false'" and it'll preven that guy from even loading.


<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server" SuppressValidationScript="false">

I tried # 2 above but I still get the error. The code is exactly as listed in the link I provided before plus the updatePanel surrounding the FormView

<atlas:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:FormViewID="FormView1"runat="server" .... >

</asp:FormView>

</ContentTemplate>

</atlas:UpdatePanel>


SuppressValidationScript="true"

Ok. The first error (above) does not show up but the next errors (which used to appear after I clicked on cancel) is still repeated for each dropdown list: "Assertion Failed: Unrecognized tag atlasControlToolkit:cascadingDropDownBehavior"


That's often related to the relative position of the controls, the extender, and the UpdatePanel. Some wiggling around of the different items can sometimes solve the problem. If it doesn't - and if the new Toolkit release doesn't help - please let us know.

CascadingDropDown not working within EditItemTemplate in Ajax Beta

I had the cascading drop down working fine inside the EditItemTemplate in a gridview with the previous Atlas CTP release. But now it stopped working with Ajax Beta 1.0. Do I need to do something different to make it work again. I tried placing Gridview.Databind() in Page_Load, but that stopped the gridview from updating back to the database.

<EditItemTemplate>

<asp:DropDownListID="ddlBuEdit"runat="server"/>

<ajax:CascadingDropDownID="ccd1"runat="server"

TargetControlID="ddlBuEdit"

Category="BU"

LoadingText="Loading Data..."

PromptText="Select Business Unit"

ServicePath="getSelectionData.asmx"

SelectedValue='<%# Eval("BusinessUnit") %>'

ServiceMethod="getBU"/>

</EditItemTemplate>

Please see if this is relevant:http://forums.asp.net/thread/1441672.aspx.

CascadingDropDown Not Cascading

I have wired 2 dropdownlists to the cascadingdropdown controls. My page code looks like this:

1<asp:DropDownList ID="StateDropDownList" runat="server" />2<ajax:CascadingDropDown ID="StateDropDownListCascadingDropDown" runat="server" Enabled="True" Category="StateName"3 PromptText="Select a state" ServiceMethod="GetDropDownStates" ServicePath="~/Site_Services/Datasets.asmx"4 TargetControlID="StateDropDownList" />56<asp:DropDownList ID="CountyDropDownList" runat="server" />7<ajax:CascadingDropDown ID="CountyDropDownListCascadingDropDown" runat="server" Enabled="True" Category="County"8 PromptText="Select a county" ServiceMethod="GetDropDownCounties" ServicePath="~/Site_Services/Datasets.asmx"9 ParentControlID="StateDropDownList" TargetControlID="CountyDropDownList" />

I've simplified the second web method to try anything to get the 2nd dropdownlist to work and no matter what, it still doesn't work. Here is the simplified method:

1 [System.Web.Services.WebMethod]2 [System.Web.Script.Services.ScriptMethod]3public CascadingDropDownNameValue[] GetDropDownCounties(string knownCategoryValues,string category)4 {5 List<CascadingDropDownNameValue> values =new List<CascadingDropDownNameValue>();6 values.Add(new CascadingDropDownNameValue("Test","Test"));7return values.ToArray();8 }

Here's what is posted:

The server returns no response. Any ideas?

j_gaylord:

5List values =new List();

Are you referring a generic List<> collection?

I got an article on Cascading dropdownlist athttp://www.aspalliance.com/1183 . Check it

Thanks


Yes. The code didn't print out properly as the Code screen in the forums ommited my < and >. I updated the code above. You'd think that it would work regardless because no matter what the values are, a value is being added to the collection. However, that's not the case.


any ideas?

nudge


Two things I would check are:

1. The webservice is decorated with [System.Web.Script.Services.ScriptService] attribute.
2. The correct web.config file and the AjaxControlToolkit.dll binary.

Thanks


Both of them are correct. I already have one drop down working. Its just the second one who's parent is the first is not.


j_gaylord:

Both of them are correct. I already have one drop down working. Its just the second one who's parent is the first is not.

In such case, the second dropdown should also fill, as the method [GetDropDownCounties] you wrote has nothing to do with the parent dropdownvalue. I have tested your code and its working fine for me. You messed up something for sure.

Thanks


Thanks for the positive insight. Any further suggestions?Wink

CascadingDropDown Method error 500

Hi,

I have a problem with cascading drop down. I tried to reproduce the video tutorial with countries and states instead of cars. I can manage to get the first one to work but the second one give me the [Method error 500]. I don't know where I made a mistake.

I really hope someone can answer me.

FMaheu

************** Web service CountryService.asmx *****Imports System.WebImports System.Web.ServicesImports System.Web.Services.ProtocolsImports System.Xml<WebService(Namespace:="http://tempuri.org/")> _<System.Web.Script.Services.ScriptService()> _Public Class CountryServiceInherits System.Web.Services.WebServiceShared _DocumentAs XmlDocumentShared _lockAs New Object Public ReadOnly Property Document()As XmlDocumentGet If (_DocumentIs Nothing)Then SyncLock _lock _Document =New XmlDocument _Document.Load(HttpContext.Current.Server.MapPath("~/App_Data/Copy of countries.xml"))End SyncLock End If Document = _DocumentExit Property End Get End Property Public ReadOnly Property Hierarchy()As String()Get Dim _HierarchyAs String() = {"country","state"}Return _HierarchyEnd Get End Property <WebMethod()> _Public Function GetDropDownContents(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As AjaxControlToolkit.CascadingDropDownNameValue()Dim knownCategoryValuesDictionaryAs New StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category)End FunctionEnd Class************************ aspx file ********<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <script runat="server"> <System.Web.Services.WebMethod()> _ <System.Web.Script.Services.ScriptMethod()> _Public Shared Function GetDropDownContentsPageMethod(ByVal knowCategoryValuesAs String,ByVal categoryAs String)As AjaxControlToolkit.CascadingDropDownNameValue()Return New CountryService().GetDropDownContents(knowCategoryValues, category)End Function </script></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server" Width="213px"> </asp:DropDownList> <asp:DropDownList ID="DropDownList2" runat="server" Width="212px"> </asp:DropDownList> <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="country" LoadingText="[Loading countries ...]" ServiceMethod="GetDropDownContents" ServicePath="CountryService.asmx" PromptText="Please select a country" TargetControlID="DropDownList1"> </cc1:CascadingDropDown> <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" ParentControlID="DropDownList1" Category="state" LoadingText="[Loading states ...]" ServiceMethod="GetDropDownContentsPageMethod" PromptText="Please select a state" TargetControlID="DropDownList2"> </cc1:CascadingDropDown> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Nevermind I kinda got it to work somehow ...Confused

Hi FMaheu,

I am having same problem as you mentioned. First dropdown works but second dropdown is giving me error "Method Error 500". Would you please let me know what change that you made on your code to fix that error.

Thank You,

Nepalaya


Hi nepalaya,

Sorry for the delay, I'm very busy these days. So instead of using a page method I used the method in my countryservice.asmx. Something seemed to be wrong with my page method and since I could just use the same method as the first cascading drop down ...

I have also read in other threads that the control could only support a limited number of objects. That could be modified in the web.config file.

I hope this helps

FMaheu

P.S. I posted my ASP.NET Code in case in would help you understand better.

1 <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="country" LoadingText="[Chargement des pays ...]"2 ServiceMethod="GetDropDownContents" ServicePath="CountryService.asmx" PromptText="Sélectionner un pays" TargetControlID="DropDownList1">3 </cc1:CascadingDropDown>4 <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" ParentControlID="DropDownList1" Category="state" LoadingText="[Chargement des états/porvinces ...]"5 ServiceMethod="GetDropDownContents" PromptText="Sélectionner un état/province" TargetControlID="DropDownList2" ServicePath="CountryService.asmx">6 </cc1:CascadingDropDown>7

Thank You very much.

Yes it works.

Thanks,

Mani


I have my code identical to yours and I am getting a method error 12030. Any ideas?

From my search, that error is given to you when your aspx page cannot reach the web service. Is your service external to your web project? If so try copy it inside your web project. It seems calling an external web service doesn't work very well with CascadingDropDown.

Hope this helps a little


my web service (.asmx file) is in my web project. It is weird, sometimes I get method error 500 errors and sometimes I get method error 12030 errors. There isn't a pattern that I can find.
Most likely the web service isn't defined or hooked up properly. The ASP.NET AJAX infrastructure is pretty unforgiving here, so make sure everything is as it should be.

CascadingDropDown List functionality anomalie

I have a bizarre problem I am not sure how to go about solving. I have a relatively complicated page that uses 2 cascading drop down lists (category, child category) to determine what records will be displayed in a GridView which can then be edited in a DetailsView control. The functionality works 100% in my development environment, but for some odd reason it breaks on my beta server. I had this same problem with a CalendarExtender control (which I swapped for an older JavaScript version to rectify) where the Calendar popup would not popup on my beta server, but worked 100% on my local environment. I downloaded the latest release ajaxtoolkit dll and associated files and updated my bin folder to no avail. Is there something I am missing? Why would my beta server function differently here?

Any thoughts on what I should check would be helpful. If it works on my local environment, I am lead to believe it is some kind of AJAX configuration problem and not a code issue.


Thanks in advance.

-Jeremy


Just in case anyone else runs into a similar issue, it turns out there was a bizarre issue with the AJAX Extensions installation. While I had installed the latest version of the AJAX Extensions and the GAC reported the latest as well, there was apparently a conflict within the Temporary files folder for the 2.0 Framework. See the following thread where I found the answer:

http://forums.asp.net/p/1123792/1772068.aspx

CascadingDropDown In a user control

Hi,

I'm trying to use the cascading dropdown control inside the edit template of a form view control which is wraped inside a user control. The cascading dropdown obtains its data from a database. Their is no problem geting the data. The issue is when I go to set the selected value of the cascading dropdown to a value in the FormView_databound event handler, the selected value is does not get set, it shows "Please Select" which is the value I set in the begining.

Please help

Please try your scenario with the recently available61106 release of the Toolkit (and ASP.NET AJAX Beta 2). If the problem persists, then please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!