Sunday, March 11, 2012

CascadingDropDown Created Dynamically does not call WebService

The service path must be an asmx fle, you cannot refer the source code file as in the above.


[delete]


I am sorry for the typing mistake. I am using asmx. But it does not work still..


how about setting autopostback to true on the dropdownlist?


it does not have to do anything with the autopostback. As soon as my page is loaded, I want dropdown to be populated with the values returned from the webservice. But it is not calling the webservice.


Are you sure the TargetID is correct, instead hardcoding, try:

ccd.TargetControlID = ddlSubject.ClientID;


tried that..does not work..the problem is that it is not giving any error. It is not emitting any java script to call the web service when I am viewing the source..


In that case i would suggest to post the full code listing or at least the dynamic control creation section.


Dim ccdAsNew CascadingDropDown

ccd.TargetControlID = ddlCabinet.ClientID

ccd.ServicePath ="CarsService.asmx"

ccd.ServiceMethod ="GetCabinets"

ccd.PromptText ="Select Cabinet"

ccd.Category ="Cabinet"

ccd.Enabled =True


I found one post which was talking about CascadingDropDownProperties for the same problem. I am not able to find CascadingDropDownProperties in the AjaxControlToolkit. Could someone tell me where this is available?


I still could not get the complete picture, You should be adding the extender in a parent control/page controls collection?


I have written the above code in the page load event in one web form


Hi Rupen,

You created the CascadingDropDown, but you didn't add it to the page.

Try this:

protected void Page_Load(object sender, EventArgs e)
{
CascadingDropDown ccd = new CascadingDropDown();
ccd.ID = "CascadingDropDown1";
ccd.TargetControlID = "DropDownList1";
ccd.ServicePath = "CarsService.asmx";
ccd.ServiceMethod = "GetCabinets";
ccd.PromptText = "Select Cabinet";
ccd.Category = "Cabinet";
ccd.LoadingText = "[Loading Cabinet...]";
form1.Controls.AddAt(2, ccd);
}

Best Regards

No comments:

Post a Comment