Wednesday, March 28, 2012

Modal Popup Extender - Setting Focus

Hi,

I have HostModalPopup.aspx webform with a ShowModalWindow button (When clicked shows a Modal Popup Window) and there are some text boxes after the button.

The Modal Pop Up window has 3 controls: a text box field, a submit button and a close button.

1) When the Modal Popup window is shown, I would like to be able to setfocus to the textbox. I thought I should be able to do this with document.getElementById('TextBox1').focus() on some event that gets triggered when the modal popup window is made visible, but I could not find any such DHTML event.

2) The taborder/tabindex of the controls in HostModalPopup.aspx, once the ShowModalWindow is opened and closed, no longer works. If I set the focus to one of the textboxes and hit tab the cursor goes to address bar instead of going to a textbox with next tabindex. I am using AJAX Control Kit verion 1.0.10606.0

Any help is greatly appreciated.

- Surya

Use ScriptManager1.SetFocus(TextBox1)


http://www.asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_SetFocus.aspx

http://msdn2.microsoft.com/en-us/e04ah0f4


Thank you guys!

The ScriptManager.SetFocus did it for the first issue.

-Surya

No comments:

Post a Comment