Welcome Guest Search | Active Topics | Sign In | Register

Set focus to dropdown in modal dialog Options
Weirs Data Processing
Posted: Sunday, April 4, 2010 9:42:42 AM
Rank: Newbie
Groups: Member

Joined: 11/25/2009
Posts: 4
I have a modal dialog with a dropdown box and a textbox on it. I want to set the focus to the dropdown box when the dialog is shown. I have tried the .focus() method from code behind and javascript, but it doesn't work. If I assign the .focus() method to a button's onclientclick method and click it after the dialog is shown, it works; but I need to set the focus when the dialog is displayed not after. I have tried the dialog's ClientSideOnLoad and ClientSideOnInitDialog. The javascript runs but it doesn't actually move the focus.

Thanks,
Fred
eo_support
Posted: Sunday, April 4, 2010 2:41:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Try to show the dialog, then set the focus to the control in a timer. It will be something like this:

Code: JavaScript
//Show the dialog
eo_GetObject("Dialog1").show();

//Set focus 300ms later
setTimeout(function()
{
    document.getElementById("id_of_your_element").focus();
}, 300);


The idea is to make sure the element is "ready" (at least visible) when you call focus.

Thanks!
Weirs Data Processing
Posted: Sunday, April 4, 2010 4:47:41 PM
Rank: Newbie
Groups: Member

Joined: 11/25/2009
Posts: 4
That worked. Thank you...
eo_support
Posted: Sunday, April 4, 2010 9:02:34 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You are welcome. Glad that it works for you!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.