0

I use the following code to perform check again a database as a user types within the textbox

<script type="text/javascript">
    function RefreshUpdatePanel() {
        __doPostBack('<%= txtUsername.ClientID%>', '');
};

and

<asp:TextBox ID="txtUsername" runat="server" AutoPostBack="True" 
onkeyup="RefreshUpdatePanel();" OnTextChanged="Code_TextChanged"></asp:TextBox>

Although this one works, the textbox loses focus after each keyup event. How can i fix that? (The whole thing resides within an update panel.)

OrElse
  • 9,709
  • 39
  • 140
  • 253

1 Answers1

0

You can use javascript as illustrated in this SO post: JavaScript set focus to HTML form element, by setting focus to an element using the client-side focus() method.

You can also use ASP.NET, by calling Page.SetFocus and supplying a control reference.

Community
  • 1
  • 1
Brian Mains
  • 50,520
  • 35
  • 148
  • 257