Retain TextBox focus on AJAX Timer Tick event in ASP.Net

Last Reply one year ago By dharmendr

Posted one year ago

i have gridview inside update panel and textbox is outside update timer tick event i m updating data of update panel updatemode=conditional.problem is that at timer tick event when gridview reload , then cursor moves out from textbox.

sir my timer tick event working properly,but there is textbox in which i type something,and after clcik on save button that text go to save in database.

problem is that if i m typing something in textbox and in between timer tick event occure, then cursor moves out from textbox,i need to again click inside textbox to type somethting.

i need if i m typing in textbox,if timer tick event occure, then my cursor will not move out from textbox or if it will always moves out then how to cursor moves in textbox at that position again on timer tick event.

You are viewing reply posted by: dharmendr one year ago.
Posted one year ago Modified on one year ago

For that you have to use JavaScript to place cursor at end of text in TextBox.


<script type="text/javascript">
    function SetFocusAtEnd(txt) {
        var length = txt.value.length;
        txt.setSelectionRange(length, length);

Call the JavaScript function on onfocus event of TextBox.