Showing posts with label drop. Show all posts
Showing posts with label drop. Show all posts

Wednesday, March 28, 2012

Change in DragDropList in new release ?

Hello,

Back in Atlas Time (6 monthes ago), I used Garbin's great exemple for a drag and drop found here:
http://aspadvice.com/blogs/garbin/archive/2006/01/17/14730.aspx

Now, after updating to the latest releases of ASPnet Ajax, I cannot make it work.

I've changed the script reference call into:
<asp:ScriptReferenceName="Microsoft.Web.Resources.ScriptLibrary.PreviewScript.js"Assembly="Microsoft.Web.Preview"/>
<asp:ScriptReferenceName="Microsoft.Web.Resources.ScriptLibrary.PreviewDragDrop.js"Assembly="Microsoft.Web.Preview"/>

The drag function (using "draggableListItem" beaviour) works well but the drop ("dragDropList" beaviour) is bugged and I get the following javascript error :

'this._activeDragSource.get_dragDataType()' is null or is not an object

Has there been a change in dragDropList in the new release? I cannot see it listed in the documentation.

Thanks in advance

Hi,

I've modified the example and the following code is working for me:

<%@. Page %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Widgets UI Example</title> <style type="text/css"> body { font-family:Verdana; font-size:11px; } .main { position:relative; width:710px; height:540px; margin:auto; } .list1 { position:absolute; left:0px; height:520px; width:340px; padding:10px 5px 10px 10px; } .list2 { position:absolute; right:0px; height:520px; width:340px; padding:10px 10px 10px 5px; } .item { background:#fff; margin-bottom:5px; background:#fff; } .itemContent { padding:5px; text-align:center; } .itemHandle { height:15px; background:#e5ecf9; overflow:hidden; border-top:solid 1px #3366cc; font-weight:bold; cursor:move; } .dropCue { border:dashed 1px #ff0000; margin-bottom:5px; } .emptyList{ font-weight:bold; text-align:center; } .centered { margin:auto; } .templates { visibility:hidden; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="scriptManager" runat="server"> <Scripts> <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" /> <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewDragDrop.js" /> </Scripts> </asp:ScriptManager> <div class="main"><%-- Left Area --%> <div id="leftArea" class="list1"> <div id="content1" class="item"> <div id="content1Handle" class="itemHandle">Content 1</div> <div class="itemContent"> <asp:Login ID="myLogin" runat="server" CssClass="centered"></asp:Login> </div> </div> <div id="content2" class="item"> <div id="content2Handle" class="itemHandle">Content 2</div> <div class="itemContent"> <asp:TextBox ID="myTextBox" runat="server"></asp:TextBox> <asp:Button ID="myButton" runat="server" Text="ClickMe" /> </div> </div> </div><%-- Right Area --%> <div id="rightArea" class="list2"> <div id="content3" class="item"> <div id="content3Handle" class="itemHandle">Content 3</div> <div class="itemContent"> <asp:Calendar ID="myCalendar" runat="server" CssClass="centered"></asp:Calendar> </div> </div> </div><%-- Templates --%> <div class="templates"><%-- Drop Cue template --%> <div id="dropCueTemplate" class="dropCue"></div><%-- Empty template --%> <div id="emptyTemplate" class="emptyList">Drop content here.</div> </div> </div> </form> <script type="text/xml-script"> <page> <components><!-- Left Area --> <control id="leftArea"> <behaviors> <dragDropList dragDataType="HTML" acceptedDataTypes="'HTML'" dragMode="Move" direction="Vertical"> <dropCueTemplate> <template layoutElement="dropCueTemplate" /> </dropCueTemplate> <emptyTemplate> <template layoutElement="emptyTemplate" /> </emptyTemplate> </dragDropList> </behaviors> </control><!-- Right Area --> <control id="rightArea"> <behaviors> <dragDropList dragDataType="HTML" acceptedDataTypes="'HTML'" dragMode="Move" direction="Vertical"> <dropCueTemplate> <template layoutElement="dropCueTemplate" /> </dropCueTemplate> <emptyTemplate> <template layoutElement="emptyTemplate" /> </emptyTemplate> </dragDropList> </behaviors> </control><!-- Draggable items --> <control id="content1"> <behaviors> <draggableListItem handle="content1Handle" /> </behaviors> </control> <control id="content2"> <behaviors> <draggableListItem handle="content2Handle" /> </behaviors> </control> <control id="content3"> <behaviors> <draggableListItem handle="content3Handle" /> </behaviors> </control> </components> </page> </script></body></html>


Yes ! It works perfect.

Thank you very much Garbin ! Smile


It's a great example.

Many thanks

Any ideas how I could save the contents after dragging

Any help on how we can get the list contents after a drop event would be good

Thanks anyway


Mike


mike963:

Any ideas how I could save the contents after dragging

Any help on how we can get the list contents after a drop event would be good

That is what I would also like to know. Also could you please Garbin provide the same code without xmlscript but with Microsoft AJAX library?

Thanx


I've been able to use the following code to make elements draggable:

$create(Sys.Preview.UI.DraggableListItem, {'handle': $get('content1Handle')}, null, null, $get('content1'));

But I haven't been able to programatically attach dragDropList behaviors because I can't figure out how to get a reference to a template. I had it working in Atlas (see: http://forums.asp.net/thread/1411942.aspx) but I had problems updating the template manager to work with MS AJAX.


Not that this will help too much, but I've been attempting the same thing. I've been spending a lot of time trying to understand exactly what the differences are between how the xml-script is parsed and run vice the imperative methods that you (and I) are trying.

A few things of note...

First, I noticed that if you call Sys.Application.getComponents(), the .length property will reveal that the imperative method will show five components are present (one for each $create call if you're mod'ing garbin's example like I am). In the declarative version, there are 10. So, after some investigating it seems that the declarative model makes one component for each DragDropList and each DraggableListItem (each behavior) and another component for each control, as a Sys.UI.Control (rightArea, leftArea, content1, content2, content3). Not sure if that's relevant just yet, but I suspect it might be.

Second, dropCueTemplates are Sys.Preview.UI.Template objects, not 'Declarative Template' objects like in AlexL's previous work around.

I've made them imperatively, but that hasn't helped in part b/c I'm not sure I'm making all the initialization params right. Looking in the previewScript.debug.js file, it looks like there's four params expected, but when I reflect on the actual dropCueTemplate that is sitting in one of the list behavior objects, it looks liek only two of them are passed by the xml-script; those are the _layoutTemplate (to be expected; and it's the dropCueTemplate DomElement), and the _parentMarkupContext.

I tried passing the list behavior a dropCueTemplate by using both the $create(Sys.Preview.UI.Template and the =new Sys.Preview.UI.Template syntax, but I think it's coming down to not knowing how to build that parentMarkupContext right. I've also tried to build one of those to pass in, but so far no joy. $create says that it doesn't support the property and using the =new has no effect at all (no error, no success). I suspect that you have to call initialize to get it to do anything, but I'm not sure why it's throwing that 'not supported' error. The Sys.Preview.UI.Template.initialize() function just deals with really basic DOM manipulation (tests if the layoutelement has a parentnode, if so it removes it from its parent node...)

Well, anyway, I need to get back to work now. T hose are my thoughts, please post here if you guys find anything adn I'll do the same.

Paul


Sorry for the thread necromancy, bu thas anyone had any luck solving this yet? I'd *really* like to be able to handle the control via js instead of xml-script...

Paul


I am looking for an option to save the position of those dragged items. I tried including a floatingbehavior to the xml-script for that control and provided

move = "OnMove" attribute value. And on the OnMove i tried to Save Profile properties. It didn't work. Any suggestions ??


Just to mention I updated the code for Atlas RC1.

Source here :

http://blog.marjanenarnout.be/index.php?entry=entry070320-224307

Monday, March 26, 2012

Catching drop event in atlas drag and drop

Hi I want to drag a GridView cell and drop it on another GridView and adding a new row in second gridview based on the dragged element name. Is there any method by which I can capture the drop event .Have you tried using theReorderList Control?

Thanks Shepherd. But I want to use drag and drop between two GridView's. ReorderList does not work properly for this purpose. Moreover I tried to use ReorderList with DataSource and it gives me error while reordering. Can u help me regarding this. And I want to execute a Insert command on drop event.

Thanks.


@.Kanwar,

To my knowledge this is not supported yet. I've read requests for this functionality on the AJAX Control Toolkit Codeplex site, but I don't know of any official plans to add it. I assume that it is possible, and that you could build it yourself if you have time...you might also look into some third party controls like Telerik or Infragistics. I don't know if they have controls like this, but they are usually a little ahead of the curve feature-wise. I hope this is helpful.


Best Regards...


Thanks. I am trying to build Ajax template for this.
Best of luck to you.

Cascasding Drop Down Page method custom variable

Hi

I have page method populating the first of my drop downs and the reason being is that i need a variable that will be specific to user.
Currently this is stored in the session...How can i use this variable in the Page Method that is static...I cant really use a static variable as they are shared between all users.

Thanks.

Steve

Hi Steve,

Unfortunately I don't know of a good way to do this anymore. When we first wrote CascadingDropDown page methods weren't required to be static so there was an easy solution. Could you create a work item on CodePlex for this? Perhaps we could modify the web service signature to include optional tag info.

Thanks,
Ted

AAAAAHHHHH!!!!!

Well i have found a solution that works for me and may well for others.....
I have a web method that has Sessions enabled that i can call to get the value from...of course this method cannot be on the page as Sessions arent static.

[

WebMethod(EnableSession =true)]
publicCascadingDropDownNameValue[] GetDivisionsBySessionIdAccount(string knownCategoryValues,string category)
{
SessionCollection oSC; if (Session["UserObj"] !=null) {
oSC = (SessionCollection)Session["UserObj"];
// Calling another method to get my array - the same one i used from the page method.
CascadingDropDownNameValue[] retArray = GetDivisionsByIdAccount(oSC.idAccount);
return retArray;
}
else {
thrownewException("Your Session Has Expired");
}
}

I have created a work item number7579 for this.

---

I have just updated to the release toolkit and now my CCDD have stopped working! The top drop down loads fine from the method above but none of the others below. I have a debug error in jsSys.Debug is null or not an object.??

ARGH!


Here's more on the typical cause of Sys.Debug is null:http://forums.asp.net/thread/1546990.aspx

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 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 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 With more then one parameter?

I am trying to use the CascadingDropDown drop down extender in a DataView.

I have three drop-downs where ddl1 contains the main lookup value. When I select ddl1, the second dropdown ddl2 populates perfectly. The problem that I have however is that the 3rd drop down is dependent on both the selected value in ddl1 and another value/column in the row. Does anyone know whether this is achievable with the CascadinDropDown extender at all? I guess i need a way to make the web service have more parameters and a way to pass the parameters to the webservice.

Any help would be highly appreciated!!

Does anyone know how I can get the Cascading DropDowns to have more then one parent id. I really need to figure out how to make the third drop down populate based on the value selected in the 1st drop down and another value from the grid... this must be acheivable.. I can't be the only one trying to do this...


Sorry, this scenario is not currently supproted by CDD.

Wednesday, March 21, 2012

CascadingDropDown OnSelectedIndexChanged event not firing

Help!!!

I have 4 drop down list boxes that are extended by the CascadingDropDown control. All of the controls populate in sequence. I am using the OnSelectedIndexChanged event of the 4th DDL to trigger an UpdatePanel. I want to take the selection from the DDL (cmbPart) and add the item to the ListBox (lbParts). When I change the selection in cmbPart, no event fires. When I press the button on the panel (btnRemovefromList) the cmbPart_SelectedIndexChanged event DOES fire before the btnRemovefromList_Click event. I have also tried to use OnSelectedIndexChanged to fire a client side javascript function and that does not fire either. However, the onblur and onclick events DO fire.

According to previous posts on this topic, it was fixed. I have the 1.0.60914.0 version of the AtlasControlToolkit.dll installed along with version 2.0.50727.60725 of Microsoft.Web.Atlas.dll.

Ken J.

Here is the code:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"EnableEventValidation="false"%>

<%@dotnet.itags.org.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %>

<!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">

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<div>

Year<asp:dropdownlistid="cmbFrom"tabIndex="2"runat="server"Width="120px">

</asp:dropdownlist>

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

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbFrom"

Category="Year"

LoadingText="{Loading Years...}"

PromptText="Select a Year"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetYears"

/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbMake"

ParentControlID="cmbFrom"

Category="Make"

LoadingText="{Loading Makes...}"

PromptText="Select a Make"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetMakes"/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbModel"

ParentControlID="cmbMake"

Category="Model"

LoadingText="{Loading Models...}"

PromptText="Select a Model"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetModels"/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbPart"

ParentControlID="cmbModel"

Category="Part"

LoadingText="{Loading Parts...}"

PromptText="Select Parts"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetParts"/>

</atlasToolkit:CascadingDropDown>

Make<asp:dropdownlistid="cmbMake"tabIndex="3"runat="server"Width="215px"></asp:dropdownlist>

Model<asp:dropdownlistid="cmbModel"tabIndex="4"runat="server"Width="250px"></asp:dropdownlist>

<INPUTid="txtPartType"type="hidden"runat="server"NAME="txtPartType">

<asp:labelid="lparterr"runat="server"Width="216px"ForeColor="Red"></asp:label>

<atlas:UpdatePanelID="upParts"runat="server"Mode="conditional">

<ContentTemplate>

Part<asp:DropDownListID="cmbPart"runat="server"Width="250px"OnSelectedIndexChanged="cmbPart_SelectedIndexChanged"></asp:DropDownList>

Selected Parts<asp:ListBoxid="lbSelected"tabIndex="10"runat="server"Width="215px"Height="85px"SelectionMode="Multiple"></asp:ListBox>

<asp:Buttonid="btnRemovefromList"style="WIDTH: 54px; font-size:xx-small"tabIndex="9"Text="Remove"

runat="server"onclick="btnRemovefromList_Click"/>

</ContentTemplate>

<Triggers>

<atlas:ControlEventTriggerControlID="cmbPart"EventName="SelectedIndexChanged"/>

<atlas:ControlEventTriggerControlID="btnRemoveFromList"EventName="Click"/>

</Triggers>

</atlas:UpdatePanel>

</div>

</form>

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<references>

</references>

<components>

</components>

</page>

</script>

</body>

</html>

And the code behind:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid cmbPart_SelectedIndexChanged(object sender,EventArgs e)

{

lparterr.Text ="test";

}

protectedvoid btnRemovefromList_Click(object sender,EventArgs e)

{

lparterr.Text ="Test";

}

}

Maybe have a look atthis post?

Thanks David.

I found that the final DDL had to have AutoPostBack set to true. I also found that using the UpdatePanel to contain only the control I want updated by the ControlEventTrigger. If the DDL controls are contained in the UpdatePanel you will see the CascadingDropDown extender refresh each of the DDLs.

Ken J.

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 Method Error 500 ?

Hello!
I looked through lots of solutions to this problem on this forum but nothing helps - I still get Method Error 500 in drop down list.
Here's the code I use:

LocationService.asmx
----------

[WebService(Namespace =http://www.lgcon.ca/)]
[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]
publicclassServiceLocation : System.Web.Services.WebService
{

[WebMethod]
[System.Web.Script.Services.ScriptMethod]
publicCascadingDropDownNameValue[] GetCountry(string knownCategoryValues,string category)
{
List<CascadingDropDownNameValue> values =newList<CascadingDropDownNameValue>();

values.Add(newCascadingDropDownNameValue("one","one"));
values.Add(newCascadingDropDownNameValue("two","two",true));

return values.ToArray();
}

}

ASPX page:
------
<asp:DropDownListID="ddlCountry"runat="server"/>
<cc1:CascadingDropDownID="cddCountry"runat="server"TargetControlID="ddlCountry"Category="Country"PromptText="Select a country"ServicePath="~/modules/location/ServiceLocation.asmx"ServiceMethod="GetCountry"/>

What am I doing wrong?

Thanks for help!

ok nevermind .. got it working .. just had to add "[System.Web.Script.Services.ScriptService]" before class declaration :)

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 Lists [Method Error 500]

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.Web

Imports 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_GetCategory1TableAdapter

myList.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

EndFunction

EndClass

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.

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