Reputation:
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
Upvotes: 0
Views: 771
Reputation: 1019
Try This,
txtState.Attributes["onfocus"] = "javascript:this.setSelectionRange(this.value.length,this.value.length);";
Upvotes: 1
Reputation: 573
This should help after focus:
txtState.SelectionStart = txtState.Text.Length -1;
txtState.SelectionLength = 0;
Upvotes: 1