Ajax Update Panel & losing focus on textboxes

Posted on 2009-04-22
Last Modified: 2013-11-08

I have a search page with numerous criteria but for the sake of example lets assume it only contains Surname and First Name textboxes.  In addition i have a "Search Criteria" section on the page which updates with what you are searching on.

All the search boxes are contained within an update panel with the textboxes set to AutoPostback.  When you enter criteria in a textbox and then click elsewhere the search criteria updates as required.

The problem is that if i enter something in surname and then click the firstname textbox the search criteria updates as expected but due to the partial postback (i'm assuming) the firstname textbox dosent retain focus.

Does anybody know of a workaround for this behaviour?

Many thanks,

Question by:stu_bill
    1 Comment
    LVL 1

    Accepted Solution

    You could add a JavaScript variable and set it for when the user is in the field. Then when your page returns use a ScriptManager.RegisterStartupScript to check the bit in the variable and set focus if necessary.

    A little messy but should work.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now