I'm having a problem getting this to work, I've tried it and I get an error message.
Error : Can't move focus to the control because it is invisble, not enabled, or of a type that does not accept focus.
Here is my code,
<script type="text/javascript">
Sys.Application.add_load(modalSetup);
function SetFocusOnControl()
{
// set the focus with javascript, e.g.: window.getElementById("xyz").focus();
document.getElementById("txt1").focus();
}
function modalSetup()
{
var modalPopup = $find('popup1'); // <. this is the BehaviorID from the ModalPopupExtender
modalPopup.add_showing(SetFocusOnControl);
}
<asp:Button ID="btn1" runat="server" Width="80px" CausesValidation="false"
Text=" Swipe Card " Visible="false" /> <asp:Button ID="btnManual" runat="server"
Width="90px" Text=" Manual Entry " Visible="false" />
<ajaxToolkit:ModalPopupExtender ID="popup1" runat="server" TargetControlID="btn1"
PopupControlID="pnl1" BackgroundCssClass="modalBackground" DropShadow="true" BehaviorID="popup1" />
<asp:Panel ID="pnl1" runat="server" CssClass="modalPopup" style="display:none;" Width="310">
<table cellpadding="1" cellspacing="0" width="300" border="0" align="center">
<tr>
<td>
<textarea rows="1" cols="10" id="txt1" onkeyup="CheckSwipe();" style="color:White;scrollbar-base-color: #FFFFFF;" class="hiddenScrollbars"></textarea>
</td>
</tr>
</table>
</asp:Panel>