Showing posts with label dropdownlist. Show all posts
Showing posts with label dropdownlist. Show all posts

Wednesday, March 28, 2012

How do I set focus on CascadingDropDown?

I'm trying to set focus on a Dropdownlist that's being populated by the nice CascadingDropDown tool. But I can't. Everything else works great, The forms retreive, insert, update without page postbacks via updatepanel. The CascadingDropDown tools work well with the dropdownlists and it all populates dependent on each other and without page postbacks. BUT I can't seem to set the focus to the dropdownlist that's being populated by the CascadingDropDown tool..

I've got the scriptmanager on the masterpage and the Dropdownlist I want to set focus upon is in a formview. I want it to set focus on the control when the form is changed to a insert or edit mode.

So my code behind is like this:

protectedvoid formView1_ModeChanged(object sender,EventArgs e)

{

if (formView1.CurrentMode ==FormViewMode.Insert || formView1.CurrentMode ==FormViewMode.Edit)

{

Master.ScriptManager1.SetFocus(formView1.FindControl("ddl_iWantFocused"));

}

}

Works great for selecting any other control in the form, but not the one populated with the CascadingDropDown.

Any help on how to set focus on this?

Let me revise that. I can SetFocus on other DropDownLists that don't use the CascadingDropDownList extender, but haven't been able to SetFocus on a Textbox.

Wednesday, March 21, 2012

How can I modify the AJAX Cascading Dropdownlist to use a Listbox as the last control

Hello - I have a need to modify the AJAX Cascading Dropdownlist where the last control is a listbox.

Just changing the last control to a listbox won't do it since I get the following error:

Unable to cast object of type 'System.Web.UI.WebControls.ListBox' to type 'System.Web.UI.WebControls.DropDownList'

To me it looks like the CascadingDropdownExtender.cs file would need to be modified but I am not sure where to start

The problem is that the targetcontrol on the extender is set to DropDownList instead ListControl which is more inclusive. You couldopen a work item for this and we will look into fixing this.