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

  • SEARCH
  • Home
  • 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 6967981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:23:32+00:00 2026-05-27T16:23:32+00:00

i want to change the label value same as textbox while i entering a

  • 0

i want to change the label value same as textbox while i entering a character. so here got a question?How can i maintain the textbox cursor after the postback ?For example i type ‘ab’. The textbox cursor position will remain at the last character which is ‘b’

Here is my coding

<script language="javascript" type="text/javascript">


 function RefreshUpdatePanel() {
     __doPostBack('<%= TextBox1.ClientID %>', '');
 };


</script>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>

    <br />
    <br />
<asp:TextBox ID="TextBox1" runat="server" onkeyup="RefreshUpdatePanel();" 
            ontextchanged="TextBox1_TextChanged"></asp:TextBox>

     <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
         <ContentTemplate>
             <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
         </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="TextBox1" />
    </Triggers>
    </asp:UpdatePanel>

    </ContentTemplate>
</asp:UpdatePanel>

my back end code

 protected void Page_Load(object sender, EventArgs e)
    {
        //--If post back is txtSearach , then do search function--
        if (Page.Request.Form["__EVENTTARGET"] == TextBox1.ClientID)
        {
            this.Label1.Text = this.TextBox1.Text;

        }

    }

I also try put textbox1.focus() while the postback event, but the textbox cursor posittion will start at the first character 🙁

  • 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-27T16:23:33+00:00Added an answer on May 27, 2026 at 4:23 pm

    What you need to do is to handle onsubmit event of form (or document) and then store the current caret position in a hidden field. On the server, read the hidden field value and then generate the start-up script to set the caret position. Tricky bits are getting and setting caret position – below links will help you in that matter:

    http://parentnode.org/javascript/working-with-the-cursor-position/
    jQuery Set Cursor Position in Text Area
    Set keyboard caret position in html textbox

    Said all that, I will recommend you to re-structure your solution. Instead of taking update-panel partial post-back on text change, you should use script services (or page methods) to make the ajax call to server for getting search results. It would be more simple, elegant and efficient. Below links should get you started:

    http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
    http://www.codeproject.com/KB/aspnet/jQuery_To_WCF.aspx
    http://msdn.microsoft.com/en-us/magazine/cc163499.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to change master page some label value from child page.
As the title suggests. I want to be able to change the label of
I want to create a fading effect of text in Label control. I change
I've got a log file that can contain the same event (Verification) multiple times,
I want to change the Text of the browse button in the FileUpload Control
I want to change the title showing in a page based on information I
I want to change the standard 3D look of the standard asp.net checkbox to
I want to change the text of a radio button (HTML element), not an
I want to change the behavior of a JavaScript used to display a banner,
I want to change member of structure under double pointer. Do you know how?

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.