简体   繁体   中英

How to set cursor after the text in a textbox on TextChange Event

I have a textbox txtZipCode . On the TextChange event, i am populating data in other two textboxes txtState and txtCity . What i want to do is, i want to set the cursor after the Text of txtState .

I am doing txtState.Focus() but, the cursor is displaying on the left side of the text...i want to set the cursor after the text.

Any Suggestions ?

Thanks in Advance

This should help after focus:

txtState.SelectionStart = txtState.Text.Length -1;
txtState.SelectionLength = 0;

试试这个, txtState.Attributes["onfocus"] = "javascript:this.setSelectionRange(this.value.length,this.value.length);";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM