Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Saturday, March 24, 2012

CascadingDropDownList and ModalPopupExtender

I have created a ModalPopupExtender that contains 3 CascadingDropDownLists. The dropdowns work and are populated normally if I don't try and set a value. If I try and set a value for the first dropdown I get an ArgumentOutOfRangeException error. It seems like the value is trying to be set before the dropdown is populated. Does anyone know how I can fix this?

Thanks.

Nevermind. I got it.

CascadingDropdownList [Method Error 500]

Still trying to get these dropdowns to work. I have created a page with a single ddl that should be populated from the web service and has no parents but I still get the [method error 500] as the values, what am I mising here?

ddl.aspx

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager id="ScriptManager1" runat="server" EnablePartialRendering="true" >
</asp:ScriptManager>

<asp:DropDownList ID="Region" runat="server" >
</asp:DropDownList>

<cc1:CascadingDropDown
Category="Region"
Enabled="true"
PromptText="Please work..."
ID="CascadingDropDown2"
TargetControlID="Region"
ServiceMethod="GetCountries"
ServicePath="CountriesByRegion.asmx"
runat="server">
</cc1:CascadingDropDown>

</form>
</body>
</html>

CountriesByRegion.asmx

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports PFCEnergy.Refining.Country.Business
Imports System.Data
Imports AjaxControlToolkit

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class CountriesByRegion
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Shared Function GetCountries(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim values As New _
System.Collections.Generic.List( _
Of AjaxControlToolkit.CascadingDropDownNameValue)

values.Add(New CascadingDropDownNameValue("foo", "bar"))
values.Add(New CascadingDropDownNameValue("bar", "foo"))
Return values.ToArray
End Function

End Class

Hi,

I too get the same error . Have you sorted the problem ?

Pls help if its working for u .

Thanks.


Yeah got it working, I added the bold and removed the struck through. Good luck.

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.Data
Imports AjaxControlToolkit

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class CountriesByRegion
Inherits System.Web.Services.WebService

<WebMethod()> _
PublicShared Function GetCountries(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim values As New _
System.Collections.Generic.List( _
Of AjaxControlToolkit.CascadingDropDownNameValue)

values.Add(New CascadingDropDownNameValue("foo", "bar"))
values.Add(New CascadingDropDownNameValue("bar", "foo"))
Return values.ToArray
End Function

End Class


Hi,

Iam not using list as u did in web method, So i thinkImports System.Collections.Generic is not needed.

Then i am not using Static (C#) in function.

So what would be wrong in my case?

Thanks.



Hi everyone, I had the same problem and after a little tweaking it works!

Here is the tip:

Please make that the database datatype matches the .NET datatype.If you have a different datatype in your database, you should TYPE CAST it to the corresponding .NET type.
string make = (string)dr["Make"];
int makeId = (int)dr["MakeID"];

.NET Framework Type

ADO.NET Database Type

SQL Data Type

String

Varchar

Varchar()

String

Nvarchar

Nvarchar()

String

NChar

Nchar()

String

NText

NText

String

Text

Text

Double

BigInt

Float

DateTime

DateTime

Datetime

DateTime

SmallDateTime

Smalldatetime

Int

Int

Int

Int64

BigInt

Bigint

Int16

SmallInt

smallint

Byte[]

Binary

Binary()

Byte[]

Image

Image

Byte[]

VarBinary

Varbinary()

Byte

TinyInt

Tinyint

Bool

Bit

Bit

Decimal

Decimal

Decimal

Decimal

Money

Money

Decimal

SmallMoney

SmallMoney

Float

Float

Float

Guid

UniqueIdentifier

Uniqueidentifier

Real

Real

Real

CascadingDropDown: Fire an Event

I have created a custom control that contains 3 CascadingDropDown boxes.

I would like to have the control fire a custom event when each of the "TextChanged" or "SelectedIndexChanged" events from the Drop Down items change.

I have added the appropriate "events" into my code behind, but they do not seem to fire. Does the JavaScript intercept them?

Any help would be greatly appreciated.

Thanks,
Bryan

The Changed events you rever to are server-side events that only fire when there's a postback. By design, CascadingDropDown doesn't do postbacks. So you don't get those events when using it. You could force a postback, but doing so would seem to negate many of the benefits of the CDD.

Mr. Anson,

Perhaps you could point me in a better direction for my needs.

The Custom Control that I have created consists of 3 CascadingDropDowns that allow the user to select a Location, Skill, and Supervisor (basically this is like the Make/Model/Color sample for the car.).

My control works fine when I incorporate a button to run a report on a different page. My Button_OnClick event can see what values are in my control, and it will send them to the new page.

I would like to incorporate my current control on a page to help narrow down yet another Drop Down List.

In the CDD example, after the user selects the Make/Model/Color, I would like to pull a list of Vehicles by Year to select.

How would I go about hooking up a new CDD that requires the control to have filled in the Make/Model/Color before it can go out and find it's data?

I thought that I could do something like placing the control and drop down list inside an update panel, but I am a little fuzzy on how to continue from there.

Would I need to set up an Atlas Trigger?

Any help that you can provide would be greatly appreciated. It would even help if you could point me in a better direction.

Thanks, Bryan


Could you add a ByYear CDD that has the Color CDD as its parent? That way it automatically populates when the Make/Model/Color are filled in. And it's welcome to call a completely different web service, so it can get whatever data it wants.

If my Make/Model/Color are in a seperate control, how will I be able to give my Year CDD the parent that is inside the control? Can I just expose the CDD as a public member?

I don't want to add the Year CDD into my control. A different page may want to populate a different CDD from the data that the control provides.


You could manually hook some script up to the "onchanged" event on the client-side select element, but it's probably ultimately the same problem as above with respect to how the Year can see into the control to get the right elements.

CascadingDropDown Selects Wrong Item on PostBack

I have a page where the cascadingdropdown is selecting the wrong item in the list on postback. I can verify that the JavaScript created by the AJAX controls says to select item "5::Description Here" yet item 4 gets selected when the page loads after post back. So you select the parent value, then the child, then click a button that does a postback (in this case a search) and when the two drop downs load the first one is selected correctly and the 2nd one, the cascading drop down, has selected the item above the correct item. If I continue to submit the form over and over the selected item just keeps moving up one spot. I attemted to remove any appended items, in my case one that says "-- Select --", as well as the prompttext as it appears to be an "index" issue, but that didn't solve the problem. I have the exact same dropdown fields on another form where they work just fine on postback. I don't want to post the whole page but here are the dropdowns in question. OfficeLocation is the parent and RateSchedule is the child.

<asp:DropDownListID="drpOfficeLocation"runat="server"AppendDataBoundItems="True"DataSourceID="srcOfficeLocations"DataTextField="Value"DataValueField="ID"Width="150px"EnableViewState="True">

<asp:ListItemValue="">-- Select --</asp:ListItem>

</asp:DropDownList>

<asp:DropDownListID="drpRateSchedule"runat="server"AppendDataBoundItems="True"

DataTextField="Value"DataValueField="ID"EnableViewState="False">

</asp:DropDownList>

<cc1:cascadingdropdownid="ccRates"runat="server"category="Location"

loadingtext="Loading Rates..."parentcontrolid="drpOfficeLocation"

servicemethod="GetRateResults"servicepath="JobAJAX.asmx"targetcontrolid="drpRateSchedule"></cc1:cascadingdropdown>

You simply won't believe what I found to be the problem. My controls are in a table that has style="display:none;" and you click an image to show the table. Removing this "display:none" from the table allowed the JS to select the correct item in the dropdown. I added it back and it selected the wrong one again. I can't make any sense of this but that's the problem.

Wednesday, March 21, 2012

CascadingDropDown method error 500

Hi,

I've created a new project following the video found here :http://www.asp.net/learn/ajax-videos/video-77.aspx

My code is the same as in the demo, but when I run the website, I have the "method error 500" in each dropdownlist instead of the makes, models and colors...

Does anyone know what this error code means ?

Thanks for your help.

Hi Dpin,

10.5 Server Error 5xx
Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has erred or is incapable of performing the request. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents should display any included entity to the user. These response codes are applicable to any request method.

10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

To resovle the kind of problem, we suggest that you should first check whether your WebService works fine or not. Then check the Control settings. If all these are ok, but your application doesn't work properly. Please add break points to your WebService and debug it step-by-step. Here is theuseful information. Please pay special attention to my last reply.

I hope this help.

Best regards,

Jonathan

CascadingDropDown load times with large amounts of data

Greetings,

I am a relative newcomer to ASP.Net AJAX. So hopefully the answer to this question will be quick and easy.

I've created a CascadingDropDown list that gets store locations based on the company. In some of these datasets there are as many as 6,000 - 10,000 records that need to be loaded into the TargetControl. This ends up being quite a lot of data. I was having problems with this origanally because of the default maxJsonLength in my webconfig which I've now corrected.

The TargetControl now gets loaded and it works with this one exception: For queries with exceptionally large datasets the client is taking up to 30 seconds or more to load the target control. I did caching on the server side in the webservice to cache data sets and that doesn't seem to be the problem. I've done some analysis with Fiddler v2.0 and it appears that the round trip request/response is taking only about a 5th of a second (see capture below):

Request Count: 1
Bytes Sent: 545
Bytes Received: 701,964

ACTUAL PERFORMANCE
-----
Requests started at: 13:58:38:1621
Responses completed at: 13:58:38:3496
Total Sequence time: 00:00:00.1875024

RESPONSE CODES
-----
HTTP/200: 1

RESPONSE BYTES (by Content-Type)
-----
~headers: 239
application/json: 701,725

So the question is: why does it take the CascadeDropDown control so long to load the data? What is client doing for the other 29.8124976 seconds?

When I did this web app in ASP.Net 2.0 (without AJAX), it was taking 2- 3 seconds max for these large data sets to load doing direct databasecalls.

Any help would be appreciated.

Thanks,

Scott Lance
Application Developer
Children's Miracle Network

I have the same problem in my application. Large sets of data are not uncommon in the large applications.

Can anybody, please, take a look at this

CascadingDropDown inside of a repeater

I'm trying to create a CascadingDropDown inside of a repeater, and just can't seem to figure it out.

I have a dropdownlist created within a repeater that should cascade from another dropdownlist that is also generated within the repeater.

The problem that arises from this situation is when I go to set the CascadingDropDownProperties, I get this error:

Object reference not set to an instance of an object.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
AtlasControlToolkit.CascadingDropDown.OnPreRender(EventArgs e) in d:\Depot\Atlas\agility\AtlasControls\MAIN\Src\ControlLibrary\CascadingDropDown\CascadingDropDownExtender.cs:60
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360


When I go through with the debugger it doesn't break on any line of code, so I'm not totally sure what's causing the error. I have figured out that the problem happens when I set the TargetControlID, because If I comment out that line then It'll work. I'm guessing I'll have the same problems with the ParentControlID, also.

cddpNew.TargetControlID = DropDownListControl.ClientID

Has anyone gotten a Cascading drop down to work within a repeater?Since that didn't work I decided to take another approach, which is to put the CascadingDropDown inside the repeater. This had it's own problem.

When trying to get the control from within the repeater during the function that handles the databinding event for the repeater I get the error:

Value of type 'System.Web.UI.Control cannot be converted to 'AtlasControlToolkit.CascadingDropDownProperties'.

So, no luck this direction either.Sad
In the first case, you probably need to access the CascadingDropDown through the Repeater container (recall that the Repeater creates many instances of its contents). The way ASP.NET implements repeaters is a little tricky, but I think you should be able to accomplish what you want with the right code.