Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6848647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:53:40+00:00 2026-05-27T00:53:40+00:00

I have the following update panel with a text field limited to 9 characters

  • 0

I have the following update panel with a text field limited to 9 characters only accepting numbers.

 <asp:UpdatePanel ID="updatePanelsearchusers" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <div class="formfieldarea">
            <div id="searchfield1" class="searchfieldbox">
                <asp:Label ID="USIDSearchlbl" runat="server" Text="USID: " CssClass="formlabel" />
                <asp:TextBox ID="USIDSearchBox" runat="server" MaxLength="9" />
                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="USIDSearchBox" ValidChars="0123456789" />
                <asp:ImageButton ID="USIDsearchbutton" runat="server" ImageUrl="/tissuebank/images/searchButton.png" CausesValidation="true" OnClick="search1_Click" CssClass="searchbutton" />
            </div>
        </div>
        <div>{output from search}</div>
    </ContentTemplate>
 </asp:UpdatePanel>

And the following JavaScript which will automatically trigger the search button if the number of characters reaches 9.

 <script type="text/javascript" language="javascript">
    function setupUSIDFocus() {
        $('#<%=USIDSearchBox.ClientID %>').focus().keyup(function () { 
           if ($(this).val().length == 9) { 
                $('.searchbutton').first().click(); 
           } 
        });
    }
    $(document).ready(function () { setupUSIDFocus(); });
 </script>  

If I have the code as above this works fine and loads with the focus being on the element USIDSearchBox as I intended, however when the update panel is updated but the event is no longer assigned to the box and the focus is lost. To fix this I added an ASP.Net Ajax control UpdatePanelAnimationExtender so that the focus and events are reassigned when the request is complete.

  <AjaxControlToolkit:UpdatePanelAnimationExtender ID="upae" runat="server" TargetControlID="updatePanelsearchusers">
      <Animations>
          <OnUpdated>
              <Sequence>
                  <Parallel duration="0">
                      <ScriptAction Script="setupUSIDFocus();" />   
                  </Parallel>             
              </Sequence>
          </OnUpdated>
      </Animations>        
  </AjaxControlToolkit:UpdatePanelAnimationExtender>

And indeed this does reset the focus and the keyup event but for some reason the element does not get focus when the page is first loaded. Though the keyup event is still attached onload I am just missing the focus being on the USIDSearchBox field. If I remove the UpdatePanelAnimationExtender then I get the focus back on load, so it must be something to do with this control.

Does anyone have any idea how to get the focus onload of the page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:53:41+00:00Added an answer on May 27, 2026 at 12:53 am

    Alternatively, you can use ‘ScriptManager.RegisterStartupScript’ in ‘search1_Click’ to call the jQuery function after ajax update:

    ScriptManager.RegisterStartupScript(this,this.GetType(),"myscript","setupUSIDFocus();",true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following update panel tag: <asp:UpdatePanel ID=UpdatePanel1 runat=server UpdateMode=Conditional onload=load()> in my
I have an ASP.NET website containing the following <asp:UpdatePanel ID=UpdatePanel1 runat=server > <ContentTemplate> <asp:Label
I have a gridview in an update panel with the following code to select
I have the following case, all my controls on an update panel on the
I have an Asp.Net 4.0 website/control interface that uses an update panel and some
I have the following really simple code <asp:ScriptManager ID=ScriptManager1 runat=server> </asp:ScriptManager> <asp:UpdatePanel ID=UpdatePanel1 runat=server>
I have an ASP.Net Update Panel which contains controls that I am trying to
i have Linkbutton inside updatePanel and when i click on it it returns following
I have the following code: UPDATE myTable SET Col1 = @Value However, I have
I have the following code: $SQL = UPDATE jobs SET read = '1' WHERE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.