locked
Textbox blinking Left sside on focus RRS feed

  • Question

  • User-807418713 posted

    Hello

    I have one textbox1 it has some word user will type after that words but on focus its showing left side like this

    But i want like this below

    How to achieve this so that on focus it should come after my refno: so easy to type

    Sunday, June 9, 2019 12:07 PM

Answers

  • User283571144 posted

    Hi Gopi.MCA,

    According to your description,I suggest you can use Javascript to focus the blink right after your text.

    More details, you could refer to below codes:

    ASPX:

    <script>
            function moveToEnd() {
    var el = document.getElementById('TextBox2')
                    el.selectionStart = el.selectionEnd = el.value.length; //Focus at the end of this textbox’s value
            }
        </script>
    

    Code-behind:

    protected void Page_Load(object sender, EventArgs e)
            {
                TextBox2.Focus();
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'>moveToEnd();</script>", false);  //Call the javascript function here
            }
    

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 11, 2019 3:17 AM

All replies

  • User283571144 posted

    Hi Gopi.MCA,

    How to achieve this so that on focus it should come after my refno: so easy to type

    According to your description, I have created a test demo on my side. It works well.

    Could you please post more details information about your codes and browser you have used? 

    If you could post more details information, it will be more easily for us to reproduce the issue and find out the solution.

    Best Regards,

    Brando

    Monday, June 10, 2019 5:55 AM
  • User-807418713 posted

    Hi

    This is my code 

    aspx page

    <asp:TextBox ID="TextBox2" runat="server" Text="Ref No:" ></asp:TextBox>

    cs page

    TextBox2.Focus();

    its blinking cursor before |RefNo: but i want blinking cursor to be come after RefNo:|

    Thanks

    Monday, June 10, 2019 6:52 PM
  • User283571144 posted

    Hi Gopi.MCA,

    According to your description,I suggest you can use Javascript to focus the blink right after your text.

    More details, you could refer to below codes:

    ASPX:

    <script>
            function moveToEnd() {
    var el = document.getElementById('TextBox2')
                    el.selectionStart = el.selectionEnd = el.value.length; //Focus at the end of this textbox’s value
            }
        </script>
    

    Code-behind:

    protected void Page_Load(object sender, EventArgs e)
            {
                TextBox2.Focus();
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'>moveToEnd();</script>", false);  //Call the javascript function here
            }
    

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 11, 2019 3:17 AM
  • User-807418713 posted

    Thank YouBrando ZWZ

    Tuesday, June 11, 2019 3:27 AM