AutoComplete does not work when put focus on that control

  • Thread starter Thread starter Pat
  • Start date Start date
P

Pat

Hi ASP Gurus,
Please help me.
Autocomplete works fine when the control does not have the focus when the
page load.
But when I put the focus on page load, then autocomplete does not work.
I even tried javascript pageload code, but with no success.
<script language ="javascript" type ="text/javascript" >
function focusIt() {
//alert('test');
var mytext =
document.getElementById('<%=txtSearch.ClientID%>');
//alert(mytext);
mytext.focus();
}
onload = focusIt;
</script>

What should I do to make it work with focus on it.

Please help, I am stuck on this for some time now.

Thanks Pat.
 
Hi ASP Gurus,
Please help me.
Autocomplete works fine when the control does not have the focus when the
page load.
But when I put the focus on page load, then autocomplete does not work.
I even tried javascript pageload code, but with no success.
 <script language ="javascript" type ="text/javascript" >
            function focusIt() {
                //alert('test');
                var mytext =
document.getElementById('<%=txtSearch.ClientID%>');
                //alert(mytext);
                mytext.focus();
            }
            onload = focusIt;
</script>

What should I do to make it work with focus on it.

Please help, I am stuck on this for some time now.

Thanks Pat.


First off, you can just set the focus in server side code with

mycontrol.focus()

It generates the proper script for the focus to happen. But I don't
see how one thing affects the other.

What browser are you talking about? Autocomplete is completely a
browser function.
 
txtSearch.Focus() was the first thing I have tried. It did not work.
I am using IE7.

Pat

Hi ASP Gurus,
Please help me.
Autocomplete works fine when the control does not have the focus when the
page load.
But when I put the focus on page load, then autocomplete does not work.
I even tried javascript pageload code, but with no success.
<script language ="javascript" type ="text/javascript" >
function focusIt() {
//alert('test');
var mytext =
document.getElementById('<%=txtSearch.ClientID%>');
//alert(mytext);
mytext.focus();
}
onload = focusIt;
</script>

What should I do to make it work with focus on it.

Please help, I am stuck on this for some time now.

Thanks Pat.


First off, you can just set the focus in server side code with

mycontrol.focus()

It generates the proper script for the focus to happen. But I don't
see how one thing affects the other.

What browser are you talking about? Autocomplete is completely a
browser function.
 
What didn't work? The focus, or the autocomplete?

Are you sure autocomplete isn't turned off in the browser?
 
Everything works if txtSearch does not have the focus when the page load.
It quit working the moment I put focus on that control at page load.
It works again if I comment that code.

Don't work means I do not see the dropdown.

Pat


What didn't work? The focus, or the autocomplete?

Are you sure autocomplete isn't turned off in the browser?
 
Back
Top