I have a Asp:TextBox at which on keyUp , i fire buttons click event , that event validates something if its validated coorectly then it proceeds but if something went wrong it gets focused on textbox but my problem is it goes at the starting position of the cursor in textbox , that's what i don't want , i want the cursor position to be at end .... here's a chunk of code :
NOTE : This button is Hidden , Code for all is :
protected void HiddenBtn_OnClick(object sender, EventArgs e)
{
if (chk > 0)
{
// Do Something
return;
}
else
{
ActSeq.Focus();
}
}
In Code-Behind :
<asp:Button ID="HiddenBtn" UseSubmitBehavior="False" TabIndex="0" Height="0" Width="0" BackColor="transparent" BorderWidth="0" OnClick="HiddenBtn_OnClick" Visible="True" runat="server" Text="Button" />
<input
id="ActSeq" runat="server"
class="form-control tooltips"
ClientIDMode="Static"
onkeyup="ClickTheBTN()"
type="text" />
In JS File :
function ClickTheBTN() {
$("[id$='HiddenBtn']").trigger("click");
return false;
}