|
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
|
|
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!
|
|
Rank: Newbie Groups: Member
Joined: 11/25/2009 Posts: 4
|
That worked. Thank you...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are welcome. Glad that it works for you!
|
|