Wednesday, March 21, 2012

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!

No comments:

Post a Comment