Showing posts with label toolkit. Show all posts
Showing posts with label toolkit. Show all posts

Wednesday, March 28, 2012

Changing focus when date selected in CalendarExtender control

This may fall more within the realm of general ASP.NET web development, but since it's regarding an AJAX Control Toolkit control, I thought it'd be best posted here.

I'm finding a "feature" of the calendar extender behavior to be be quite annoying. It seems that by default when a date is selected on the calendar and the selected date displays in the associated textbox, the calendar itself stays displayed and the only way I've found to get rid of it is to click anywhere outside the calendar itself. You can't tab out of it to the next textbox, Enter won't get rid of it, etc.

I'm sure there's a way to have the calendar collapse when the date is changed, but I just don't know how - could someone provide a way to do this?

Here's the code for my calendarextender:

<asp:TemplateField HeaderText="Date"><ItemTemplate><asp:Label ID="lblWeatherDate" runat="server" Text='<%# Bind("WeatherDate", "{0:dd-mm-yyyy}")%>' /></ItemTemplate><EditItemTemplate><%-- OnTextChanged="txtWeatherDate_OnTextChanged" --%><asp:TextBox ID="txtWeatherDate" Text='<%# Bind("WeatherDate")%>' runat="server"TabIndex="0" Width="80px" Font-Size="10px" /><ajaxToolkit:MaskedEditExtender ID="editExtWeatherDate" runat="server" TargetControlID="txtWeatherDate" Mask="99/99/9999" MaskType="Date" MessageValidatorTip="True" OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError" ErrorTooltipEnabled="True" /><ajaxToolkit:MaskedEditValidator ID="editValidatorWeatherDate" runat="server" ControlExtender="editExtWeatherDate" ControlToValidate="txtWeatherDate" IsValidEmpty="True" InvalidValueMessage="Invalid entry. Select a date from the calendar or enter the format "mm\dd\yyyy"" Display="Dynamic" InvalidValueBlurredMessage="Error" /><ajaxToolkit:CalendarExtender ID="calExtWeatherDate" runat="server" Enabled="True" TargetControlID="txtWeatherDate" Format="MM/dd/yyyy" /></EditItemTemplate></asp:TemplateField>

As you can see I tried messing with the OnTextChanged of the textbox and started up with this code:

Sub txtWeatherDate_TextChanged(ByVal senderAs Object,ByVal eAs EventArgs)Handles txtWeatherDate.TextChangedDim txtWeatherDateAs TextBox =Me.gvWeather.FindControl("txtWeatherDate")txtWeatherDate.End Sub

But I couldn't figure out where to go with that. I was looking for something to do with changing the focus of the textbox, but couldn't figure that out.

Any help would be greatly appreciated.

Thanks!

this is in c# but this is how i get the calendar extender to close on date click

to close the calendar onClick i set this up in the code behind

//Hide the calendarprotected override void OnLoad(EventArgs e) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"hideCalendar", @."function hideCalendar(cb) { cb.hide(); }",true);base.OnLoad(e); }

and this is what the asp code looks like

 <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate" OnClientDateSelectionChanged='hideCalendar'>

Hey, keyboardcowboy

Thanks for the code. It was pretty much a copy-paste thing. The C# converted nicely in a code converter. After selecting the date, the calendar disappears, as it should.

However, the oddest thing is happening now: The date displays in the date label as "dd-00-yyyy". I.e. the proper date number,two zeros for the month, then the proper year. This is regardless of what formatting I use for either the extender or the textbox (I was usingFormat="MM/dd/yyyy" in the extender). The date in the sql table it's coming from is correct and the date can be changed and saved (this is in a gridview) properly and it is even displayed properly when the textbox is showing while the gridview is in edit mode. It's just messed up in the label.

I was using the following for the bound text value for the date label:Text='<%# Bind("WeatherDate", "{0:dd-mm-yyyy}")%>'.When I remove the formatting string the date displays properly, but with the time as well. I can't get the date formatted to mm-dd-yyyy now!

Any thoughts?

Thanks


Okay, I caught one thing I was doing wrong: I was using two different formats: dd-mm-yyyy in the label and mm-dd-yyyy in the textbox.

But unfortunately, getting those two to the same format didn't fix the display problem. It's still displaying the month as two zeros (00). And that's regardless of whether I set the format as dd-mm-yyyy or mm-dd-yyyy.

Weird...


weird. maybe if that format string you are trying doesnt work you can try this .ToShortDateString(); that will display a date but without the time. it works in c# in sure it does in vb also so try this (not sure if it will work because i think casting types is different in vb)

Text='<% # ((DateTime)Bind("WeatherDate")).ToShortDateString()%>'


Yeah - I tried just putting it in my label, but got a build error, saying "DateTime" is a type and cannot be used as an expression. I don't know quite enough to know how to change it to work for my VB code.


Okay - found out CDate is used for casting dates. But I can't find quite the right syntax. I've tried: Text='<%# Bind(CDate("WeatherDate")).ToShortDateString() %>' , and Text='<%# CDate(Bind("WeatherDate")).ToShortDateString() %>' and even Text='<%# Bind((CDate("WeatherDate")).ToShortDateString()) %>' so far, but got build errors saying the Bind was not well formed.

Anyone know what the correct syntax would be in this case?

Thanks


I would make a new topic for the problem with your date and give it a title about the date. Some people will know how to do this in vb but will not check this post because it is about calendar stuff :P


Good idea. Will do. Thanks for your help - you got me further than I was an hour ago!

Regards

Monday, March 26, 2012

Catch async trigger in page_load

Hi guys,

I've recently started experiencing with the ASP.NET AJAX toolkit and I'm wondering if it's possible to catch the async trigger in the page_load and what object caused it?

This is in the situation that I have a lot of database accesses in the app. I want to be able to trigger really specific calls to the DB depending on if it's a postback, async call, etc. Not just a generic thing that's executed in the !isPostback section, causing the application to fetch a lot of data for a small AJAX call.

Thanks,

Ben.

if (ScriptManager1.IsInAsyncPostBack)if (ScriptManager1.AsyncPostBackSourceElementID == yourControl.ID){ // do your thang }

Awesome, thanks!

Ben.

Saturday, March 24, 2012

CascadingDropDown screen flicker

I have loaded the Beta 1.0 Ajax Extensions as well as release 61020 of the Ajax Control Toolkit.

I followed the migration documentation and notice that the CDD controls that I am using cause the entire browser screen to flicker.

This was NOT the case with the previous release. It occurs on the Ajax Control Toolkit demo site as well as in the example project. Postback elimination was one of the primary reasons for my using these controls.

What gives?

Ken J.

It's still not posting back, so that's not the issue. It looks fine to me in IE7, so could you please indicate which browser(s) do/do not exhibit the problem for the demo site athttp://ajax.asp.net/ajaxtoolkit/?

Wednesday, March 21, 2012

CascadingDropDown Sample problem, Method Error 500

Hi

I've downloaded the last version of Control Toolkit and I've installed it. When I try to run the WebSampleSite, everything works fine except CascadingDropDown, The first combo says "Method Error 500". Any ideas?

Please help...

to me Method Error 500 is webservices error

try look webservices area..make sure it gets call (you can debug into it)

CascadingDropDown require EventVlidation=false?

I turned on event validation (=true) of the Atlas Control Toolkit sample -> CascadingDropDown .

When I click the , Error message suggest turn event validation off.

Is this a must?

I saw some thread showing that they can add an attribute "SuppressEventValidation", but I can't see smart tag/ code hints in my version? Is it a new feature in later built of atlas?

Please advice how to keep EventValidated ?

This thread explains why I believe EnableEventValidation needs to be false:http://forums.asp.net/thread/1281139.aspx

Thanks for your kindly reference, It's really a time for me to choose between SECURITY , USABLITILY

I need to sacrifice security , choose usablitiliy

CascadingDropDown PromptText -- CSS?

Is there any way to assign a CSS-property to the PromptText property of the CascadingDropDown?

I have attempted modifying the Toolkit (CascadingDropDownBehavior.js):

_setOptions :function(list, inInit, gettingList)

// code omitted

if (headerText) {

var optionElement =new Option(headerText,"");

optionElement.className = "PromptText";

e.options[e.options.length] = optionElement;

}

But this didn't workSad Any ideas?

Thanks in advance.

Well, I found a workaround... Forgot to post here. For those interested, I wrote about this in my blog:

http://haltenberg.blogspot.com/2007/02/cascadingdropdown-passing-additional.html

CascadingDropDown Problems......

Hello,

I am trying to create a vb.net 2005 web page using the Atlas cascadingdropdown control from the toolkit. Ideally I would like it to work like the sample demonstration at:

http://atlas.asp.net/atlastoolkit/CascadingDropDown/CascadingDropDown.aspx

But I can't seem toget it to work. Does someone have a working sample (vb or c#) of doing it the same way? By the same way I mean, when the page loads displaying multiple drop down lists with the first list populated and showing the watermark, and the rest of the dropdowns showing the watermark but disabled. When any item in the first drop down is selected, it should populate and enable the second drop down, etc.

When I code it, the first and second drop downs are disabled, enabled properly, but when I perform the callback from the first dropdown having changed, for some reason it is not recorded as changed within the code behind in tha application. What I have for my web page and code behind is (note that ddlCatalogItem is the first drop down, and ddlFrontImage is the second). Note that in the code behind in the procedure ddlCatalogItem_SelectedIndexChanged the value ddlCatalogItem.SelectedValue is not correct! Why?

<tr>

<tdstyle="width: 76px; text-align: right"class="formheading"valign="top">

Catalog Item

</td><tdstyle="width: 278px"valign="top"><asp:DropDownListID="ddlCatalogItem"runat="server"CssClass="formheading"AutoPostBack="True"OnSelectedIndexChanged="ddlCatalogItem_SelectedIndexChanged"></asp:DropDownList></td></tr><tr><tdstyle="width: 76px; text-align: right"class="formheading"valign="top">

Front Image

</td><tdstyle="width: 278px"valign="top"><atlas:UpdatePanelMode=ConditionalID="UpdatePanel1"runat="server"><ContentTemplate><asp:DropDownListID="ddlFrontImage"runat="server"CssClass="formheading"></asp:DropDownList></ContentTemplate><Triggers><atlas:ControlValueTriggerControlID="ddlCatalogItem"PropertyName="SelectedValue"/></Triggers></atlas:UpdatePanel></td></tr>

And in the code behind for that page I have:

ProtectedSub ddlCatalogItem_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)

BindImageList(ddlCatalogItem.SelectedValue)

EndSubPrivateSub BindImageList(ByVal CatalogItemIDAsInteger)Dim sqlConn1AsNew SqlConnection()Dim drAs SqlDataReader

sqlConn1.ConnectionString =

"Data Source=PD-dev;Initial Catalog=Tapestry;Persist Security Info=True;User ID=sa;Password=s@dotnet.itags.org.w*"

sqlConn1.Open()

Dim oSQLAsNew SqlCommand("spReadFrontImageByCatalogItem", sqlConn1)

oSQL.CommandType = CommandType.StoredProcedure

' Add the parameters to the command object

oSQL.Parameters.Add(

"@dotnet.itags.org.CatalogItemID", SqlDbType.SmallInt, 0).Value = CatalogItemID' Run the stored procedureTryDim ImagesAsNew DataTable("Images")

Images.Columns.Add(

"Description", System.Type.GetType("System.String"))

Images.Columns.Add(

"ProductFamilyID", System.Type.GetType("System.String"))

dr = oSQL.ExecuteReader

Images.Load(dr)

ddlFrontImage.DataSource = Images

ddlFrontImage.DataTextField =

"Description"

ddlFrontImage.DataValueField =

"ProductFamilyID"

ddlFrontImage.DataBind()

Catch exAs SqlException

MsgBox(ex.Message, MsgBoxStyle.Critical,

"Error")EndTry

sqlConn1.Close()

EndSub

Thanks!

Jim

Hi jjr -

Looking at your code, I don't see the CascadingDropDown extender declared anywhere.

Take a look at the walk through on my blog and post again if you're still having troubles:

http://blogs.msdn.com/sburke/archive/2006/04/14/576421.aspx

Thanks,

Shawn


Hi Shawn,

When I take out my ddlCatalogSelectedIndexChanged function, and set up the extender, I only see a blank list from my webservice. The webservice functions are defined as shown below.. why won't those return anything to my drop down listboxes?

the web page extender definition

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server"><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlCatalogItem"Category="Item"PromptText="Select item to order"ServicePath="ListcountService.asmx"ServiceMethod="GetCatalogItems"/><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlFrontImage"ParentControlID="ddlCatalogItem"PromptText="Select the front image"ServiceMethod="GetImages"ServicePath="ListcountService.asmx"Category="Image"/></atlasToolkit:CascadingDropDown>

the webservice code

:

<WebMethod()> _

PublicFunction GetImages(ByVal knownCatelogItemsAsString,ByVal ItemAsString)As CascadingDropDownNameValue()Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCatelogItems)Dim ItemIdAsIntegerIf (Not kv.ContainsKey("Item")OrNot Int32.TryParse(kv("Item"), ItemId))ThenThrowNew ArgumentException("Couldn't find Item.")EndIfDim sqlConn1AsNew SqlConnection()Dim drAs SqlDataReader

sqlConn1.ConnectionString =

"Data Source=PD-dev;Initial Catalog=Tapestry;Persist Security Info=True;User ID=sa;Password=s@.w*"

sqlConn1.Open()

Dim oSQLAsNew SqlCommand("spReadFrontImageByCatalogItem", sqlConn1)

oSQL.CommandType = CommandType.StoredProcedure

' Add the parameters to the command object

oSQL.Parameters.Add(

"@.CatalogItemID", SqlDbType.SmallInt, 0).Value = ItemId' Run the stored procedureTry

dr = oSQL.ExecuteReader

Catch exAs SqlExceptionEndTry

sqlConn1.Close()

Dim valuesAsNew List(Of CascadingDropDownNameValue)()Dim drowAs DataRowForEach drowIn dr

values.Add(

New CascadingDropDownNameValue(drow("Description"), drow("ProductFamilyID").ToString()))NextReturn values.ToArray()EndFunction

<WebMethod()> _

PublicFunction GetCatalogItems()As CascadingDropDownNameValue()Dim sqlConn1AsNew SqlConnection()Dim drAs SqlDataReader

sqlConn1.ConnectionString =

"Data Source=PD-dev;Initial Catalog=Tapestry;Persist Security Info=True;User ID=sa;Password=s@.w*"

sqlConn1.Open()

Dim oSQLAsNew SqlCommand("spGetAllCatalogItems", sqlConn1)

oSQL.CommandType = CommandType.StoredProcedure

' Run the stored procedureTry

dr = oSQL.ExecuteReader

Catch exAs SqlExceptionEndTry

sqlConn1.Close()

Dim valuesAsNew List(Of CascadingDropDownNameValue)()Dim drowAs DataRowForEach drowIn dr

values.Add(

New CascadingDropDownNameValue(drow("Description"), drow("ID")))NextReturn values.ToArray()EndFunction

Thanks!

Jim


My guess is because of this spelling typo. The way Atlas does it's webservice proxies, the names need to be exact.

Public Function GetImages(ByVal knownCatelogItemsAs String,ByVal ItemAs String)should bePublic Function GetImages(ByVal knownCategoryItemsAs String,ByVal categoryAs String)

Hi Jim,

I've played with the code you provided and tweaked it to work on my machine. I removed your data access code in the webservice and filled it with stubs. Here's the.aspx page:

<%@. Page Language="VB" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %><!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>Test Page</title></head><body><form runat="server"><div> <atlas:ScriptManager ID="ScriptManager1" runat="server" /> <table> <tr> <td align="right">Catalog Item</td> <td><asp:DropDownList ID="ddlCatalogItem" runat="server"></asp:DropDownList></td> </tr> <tr> <td align="right">Front Image</td> <td><asp:DropDownList ID="ddlFrontImage" runat="server"></asp:DropDownList></td> </tr> </table> <atlasToolkit:CascadingDropDown ID="cdd" runat="server"> <atlasToolkit:CascadingDropDownProperties TargetControlID="ddlCatalogItem" Category="Item" ServicePath="ListcountService.asmx" ServiceMethod="GetCatalogItems" PromptText="Select item to order" /> <atlasToolkit:CascadingDropDownProperties TargetControlID="ddlFrontImage" ParentControlID="ddlCatalogItem" Category="Image" ServicePath="ListcountService.asmx" ServiceMethod="GetImages" PromptText="Select the front image" /> </atlasToolkit:CascadingDropDown></div></form></body></html>

And here's the code for the web service:

Imports System.Web.ServicesImports AtlasControlToolkit<WebService(Namespace:="http://tempuri.org/")> _<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _Public Class ListcountServiceInherits System.Web.Services.WebService <WebMethod()> _Public Function GetCatalogItems(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()Return New CascadingDropDownNameValue() _ {New CascadingDropDownNameValue("Fruit", 0),New CascadingDropDownNameValue("Vegetable", 1)}End Function <WebMethod()> _Public Function GetImages(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Dim ItemIdAs Integer If (kv.ContainsKey("Item")And Int32.TryParse(kv("Item"), ItemId))Then If (ItemId = 0)Then Return New CascadingDropDownNameValue() _ {New CascadingDropDownNameValue("Apple", 2), _New CascadingDropDownNameValue("Pear", 3), _New CascadingDropDownNameValue("Banana", 4)}ElseIf (ItemId = 1)Then Return New CascadingDropDownNameValue() _ {New CascadingDropDownNameValue("Potato", 5), _New CascadingDropDownNameValue("Lettuce", 6), _New CascadingDropDownNameValue("Corn", 7)}End If End If Return New CascadingDropDownNameValue() {}End FunctionEnd Class

A couple of things to note:
- You need to implement the default constructor forCascadingDropDownNameValue as menionted in David's last post athttp://forums.asp.net/thread/1257783.aspx.
- Instead of throwing exceptions in your web services you should return an empty list if you have no data to fill. I believe it's the expectation made by theCascadingDropDownBehavior.

If this doesn't work or you have any other questions, just let us know.

Thanks,
Ted


I think I have most of it working now, but I am curious, how do I do the enabling / disabling of the second list box in the cascade? I would like the second listbox to be disabled on start of the web page, and then enabled only if the 'select' option is not chosen in the first listbox; and I cannot seem to figure out how to do that!

I do have the listboxes being filled properly and the first listbox successfully loads the second!

However, I do note that the webservice function to load the second list is called on page startup, at which time I have not yet selected anything, is there a way to buypass this extra call?

Thanks!

Jim


Hi Jim,

Are you throwing exceptions in your web service methods? I believe that throwing exceptions instead of returning an empty list causes behavior similar to what you're describing. If that's not the case though, feel free to post your code again and we can take a look.

Thanks,
Ted


Forget my last question, it all works now!

Now I am down to a very basic question, can I have it so when I change the selection in the first dropdownlist in the cascade, that it always resets the second dropdownlist in the cascaed to the first watermark item which is 'select...'?

How would I do that?

Thanks!

Jim


Hi Jim,

If I understand what you're asking, I think this should happen automatically. The working code I posted above does this on my machine. If you're experiencing different behavior, take a careful look to see if anything is different. If it all looks the same though, you can post your code and I'll take another look.

Thanks,
Ted

Ted,

In mine, if I select an item from the second dropdown, and then change the first dropdown, the second doesn't automatically change to select like I would expect... instead it stays on a different item... is that how it is supposed to work?

Jim


Hi Jim,

It is supposed to work exactly like you want it to. I'm not sure what you're doing different that has it acting funny. My guess would be that somehow your web services aren't working with the controls perfectly. Make sure your parameter names exactly match those in the sample. Shawn mentioned this above, but made a slight typo. Here's what they should look like (in C# and VB):

public AtlasControlToolkit.CascadingDropDownNameValue[] GetXXXXX(string knownCategoryValues,string category){}
Imports AtlasControlToolkitPublic Function GetXXXXX(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()End Function

If this doesn't help fix the problem, just keep posting with more details.

Thanks,
Ted


I'm not sure if the problem I'm having is similar or not, but I'm hoping someone can help me find a solution to my issue.

My webservices and atlas don't seem to want to play nicely together. My drop downs appear blank if I try to use web services to provide the data, but work fine if I use built in page methods.

Just to be sure, I copied the code for the vegetables mockup supplied here, and sure enough, if I used a webservice called listcountservice, my drop down was blank.

So I movd the code into my test page, and everything works fine. Just to be sure, my code works fine if I do the following:

<atlas:ScriptManagerID="ScriptManager1"runat="server"/><table><tr><tdalign="right">Catalog Item</td><td><asp:DropDownListID="ddlCatalogItem"runat="server"></asp:DropDownList></td></tr><tr><tdalign="right">Front Image</td><td><asp:DropDownListID="ddlFrontImage"runat="server"></asp:DropDownList></td></tr></table><atlasToolkit:CascadingDropDownID="cdd"runat="server"><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlCatalogItem"Category="Item"ServiceMethod="GetCatalogItems"PromptText="Select item to order"/><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlFrontImage"ParentControlID="ddlCatalogItem"Category="Image"ServiceMethod="GetImages"PromptText="Select the front image"/></atlasToolkit:CascadingDropDown>

and in the .vb

Imports

System.Web.Services

Imports

AtlasControlToolkit

Partial

Class spellvault_testInherits System.Web.UI.Page

<WebMethod()> _

PublicFunction GetCatalogItems(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()ReturnNew CascadingDropDownNameValue() _

{

New CascadingDropDownNameValue("Fruit", 0),New CascadingDropDownNameValue("Vegetable", 1)}EndFunction

<WebMethod()> _

PublicFunction GetImages(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Dim ItemIdAsIntegerIf (kv.ContainsKey("Item")And Int32.TryParse(kv("Item"), ItemId))ThenIf (ItemId = 0)ThenReturnNew CascadingDropDownNameValue() _

{

New CascadingDropDownNameValue("Apple", 2), _New CascadingDropDownNameValue("Pear", 3), _New CascadingDropDownNameValue("Banana", 4)}ElseIf (ItemId = 1)ThenReturnNew CascadingDropDownNameValue() _

{

New CascadingDropDownNameValue("Potato", 5), _New CascadingDropDownNameValue("Lettuce", 6), _New CascadingDropDownNameValue("Corn", 7)}EndIfEndIfReturnNew CascadingDropDownNameValue() {}EndFunction

End

Class

But not if I do it using the supplied web service. I'd appreciate it if anyone could give me a pointer towards where I'm apparantly misconfiguring my webservices or what not (I have tested and my web services do work fine by themselves, just not via the atlas extender)

Never mind. I eventually figured out that I needed some additional code

<

sectionname="webServices"type="Microsoft.Web.Configuration.WebServicesSection"requirePermission="false" />

and

<

webServicesenableBrowserAccess="true"/>

inside the microsoft.web section.

Thanks though!

CascadingDropDown Problem

Hi All

I'm using the latest release of the toolkit. I'm building a CascadingDropDown and am getting a 12030 method error when I use a remote service (rather than have the service in the same project).

<cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="ddlMake" Category="Make" PromptText="Please select a make" LoadingText="[Loading makes...]" ServicePath="~/../CarServiceLocal/CarService.asmx" ServiceMethod="GetDropDownContents"/>

If I set the Service path to a local asmx file it works fine ServicePath="CarService.asmx"

But if I change it to be a remote service

ServicePath="~/../CarServiceLocal/CarService.asmx"

or

ServicePath="http://localhost/CarServiceLocal/CarService.asmx"

Then I get the 12030 method error.

Does anyone have any ideas?

Cheers


Craig

The CDD sample page uses the ~ syntax, so I'm reasonably confident it works in general. Your use of it with ".." makes me wonder if it works like you think it does. I'd say to double-check that the final path that gets used is correct.

CascadingDropDown List 1-dimensional array error

I'm trying to get the CascadingDropDown from the Atlas toolkit to work with a database. I receive this error at the lineReturn values.ToArray().

Error 1 Value of type '1-dimensional array of AtlasControlToolkit.CascadingDropDownNameValue' cannot be converted to 'AtlasControlToolkit.CascadingDropDownNameValue'

Here is the WebMethod.

<WebMethod()> _

PublicFunction GetMakes(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue

Dim makeAdapterAs CarsTableAdapters.MakeTableAdapter =New CarsTableAdapters.MakeTableAdapter()

Dim makesAs Cars.MakeDataTable = makeAdapter.GetMakes()

Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)()

ForEach drAs DataRowIn makes

Dim makeAsString =CStr(dr("Make"))

Dim makeIdAsInteger =CInt(dr("MakeID"))

values.Add(New CascadingDropDownNameValue(CStr(dr("Make")), dr("MakeID").ToString()))

Next dr

Return values.ToArray()

EndFunction

Any Ideas?

Rgds

Dave

Replace

PublicFunction GetMakes(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue

With

PublicFunction GetMakes(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()

CascadingDropDownNameValue() is an array, butCascadingDropDownNameValue is not


Thanks lotusinriver. It works perfectly now.

Dave


You are very welcome.

CascadingDropDown Javascript error "Access is Denied."

Hi All,

I am trying to use the CascadingDropDown control from the AJAX Toolkit, but I recieve a Javascript "Access is Denied." error when I run the page. Googling off and on for the past couple of days hasn't yielded many possible solutions. The only one that looked promising washere but it didn't work in my case. The one piece thats different in my code than the examples I've found is that I'm trying to use an external Web Service/Method. The examples I've found all contain the .asmx file in the same project as the CascadingDropDown.

Information Regarding the Error
File: MicroSoftAjax.debug.js
Line: 4079
Code: this._xmlHttpRequest.open(verb, this._webRequest.getResolvedUrl(), true );
The page has a disabled DropDownList with the text "Loading States..." in it.

ASPX Code

 <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="http://l3y9ypb1/IDSWebService/IDSCommon.asmx" /> </Services> </asp:ScriptManager> <ajax:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="Town" LoadingText="Loading states..." PromptText="Select a state..." ServiceMethod="getCDDTowns" ServicePath="http://l3y9ypb1/IDSWebService/IDSCommon.asmx" TargetControlID="DropDownList1"> </ajax:CascadingDropDown> <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList> </div> </form>

Web Service Code - This Web Method works properly. The only reason I'm posting it is to make sure I didn't make any mistakes with the Service/Method attributes.

using AjaxControlToolkit;using IDSUtility;using System;using System.Collections.Generic;using System.Collections.Specialized;using System.Data;using System.Web;using System.Web.Script.Services;using System.Web.Services;using System.Web.Services.Protocols;[System.Web.Script.Services.ScriptService()][WebService(Namespace = 'http://tempuri.org/')][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]public class IDSCommon : System.Web.Services.WebService{public IDSCommon() { } [ScriptMethod] [WebMethod]public CascadingDropDownNameValue[] getCDDTowns(string knownCategoryValues,string category) {string districtCode ="05";return Utility.getCDDVArrayFromDataTable(Utility.getDataTableFromStoredProcedure("districtCode", districtCode,"cursorTowns","getTowns","TOWNS"),"TOWN_NAME","TOWN_CODE"); }}

I'd appreciate any information regarding this problem.

Thanks,
Andy

I think you may be hitting cross-domain limitations that are outlined here and in the linked article discussing a related issue:http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx


Hi Andy,

XmlHttpRequest doesn't support cross domain posting, so you can't use a web service in a different domain.

You may solve it by adding a proxy web service in the same domain, and this web service simply expose a serials of methods similar to the remote web service's. It internally calls the remote web service to implement.

On your page, register the web service within the same domain instead.

Hope this helps.


Thank you very much, that did the trick!