I eventually managed to get something working. So, in case someone else has a similar problem, here is what I did:
- In the Page_Load of the user control I pass back the ClientID of the textbox like this :
ScriptManager.RegisterClientScriptBlock(this, GetType(), "txtSearchBarcode", "var _txtSearchBarcode = '" + txtSearchBarcode.ClientID + "';", true);
Then on the main page(which contains the Tab Container), I added this javascript:
function getControl_TabClicked2(sender, e) {
control = $get(_txtSearchBarcode);
}
function setFocus(sender, e) {
try{
control.focus();
}
catch(e){
//do nothing
}
} The Tab Container line looks like this :
<cc1:TabContainer ID="tcMain" runat="server" CssClass="ajax__tab_yuitabview-theme" OnClientActiveTabChanged="setFocus">
And finally the specific TabPanel :
<cc1:TabPanel ID="tcSearch" runat="server" HeaderText="Search" OnClientClick="getControl_TabClicked2">
This is an amalgamation of a few different solutions I found on the net, hopefully it will help someone else.
Cheers,
Jim