1

On selecting dropdown list a value is displayed on the textbox but the cursor position is on the beginning of textbox. But I need to show it after the value on the textbox.

protected void drgBranches_SelectedIndexChanged(object sender, EventArgs e)

    {
        txtLoginName.Text = drgBranches.SelectedValue;
        txtLoginName.Focus();
    }

It works fine in google chrome and IE. But it doesn't work on Firefox.

RENJITH VS
  • 99
  • 13

1 Answers1

0

Solution using just jQuery :

$('#txtLoginName').focus();
$('#txtLoginName').val($('#txtLoginName').val())

Check this post Set Focus After Last Character in Text Box where is different examples how to do this, but this one is the easiest.


Update for FF :

To make it work in FF firstly clear textBox value and then set it again

    var val = $('#txtLoginName').val();
    $('#txtLoginName').val('');
    $('#txtLoginName').val(val);

Live Example : JsFiddle

Community
  • 1
  • 1
demo
  • 6,038
  • 19
  • 75
  • 149