Search This Blog

Thursday, November 3, 2011

TabContainer Setting Focus to a control inside the TabPanel

 Place this at the BOTTOM of your ASP.Net Page.  Replace txtPartNo with the name of your control.



<script language="javascript" type="text/javascript">
   
Sys.Application.add_load
   
(
       
function()
       
{
            window
.setTimeout(focus, 1);
       
}
   
)
   
function focus()
   
{
        document
.getElementById('<%=txtPartNo.ClientID %>').focus();
   
}
</script>

2 comments:

  1. Thank you man. Searching for this for a long time. This is working. But can you explain me the code as it would be helpful.

    ReplyDelete
  2. Also my requirement is this.

    I want to set the focus in different textboxes inside tabcontainer based on certain condition checks. In simple words, can we change the focus dynamically?

    ReplyDelete