Reputation: 2148
I have a bootstrap modal popup which has the first first a dropdownlist and I want the user to be able to table through the fields without having to use the mouse to set the focus in the modal popup. I can do this fine if the first field is a text box, but when it is a dropdownlist I can't get this to focus using the ddl_list.Focus() command.
Upvotes: 1
Views: 765
Reputation: 2148
This was solved after some further searching. Simply add the following javascript to the aspx file. This sets focus to the field field in a bootstrap popup modal.
<script type="text/javascript">
$('body').on('shown.bs.modal', function (e) {
var ele = $(e.target).find('input[type=text],textarea,select').filter(':visible:first'); // find the first input on the bs modal
if (ele) {ele.focus();} // if we found one then set focus.
})
</script>
Upvotes: 1