views:

37

answers:

1

Hi every1,

I have a question about the ASP.NET Updatepanel. My problem is that I will set the focus on a textbox after loading the datasource in the Updatepanel. How can I control it ? The best solution for me is the option with JavaScript. But it's not mandatory.

Thank's for help !

A: 

Try this :

<script type="text\javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(RunThisAfterEachAsyncPostback);
// runs each time postback is initiated by any update panel on the page
function RunThisAfterEachAsyncPostback()
{
  document.Form1.MyTxtBox.focus() 
  //alert('Javascript, baby!');
}
</script>
Pranay Rana
Hi, I have tried it and it operates. But the focus isn't on the textbox. I believe that the focus() is quick on the textbox and than gone.
Patrik