Focus on TextBox inside TabContainer

I have a custom Login screen in a Tab Container

     <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="true" OnActiveTabChanged="TabContainer1_ActiveTabChanged" CssClass="MyTabStyle">
                <asp:TabPanel ID="uxStandardTab" runat="server" HeaderText="Login">
                        <table width="320px" border="0" style="border-width: 0px;">
                                    <cc1:LabeledTextBox ID="Username" runat="server" Required="true" LabelText="Email/User Name" LabelWidth="120" ControlWidth="150" LabelCss="FormLabelText BoldText" ValidationGroup="Standard"></cc1:LabeledTextBox>
                                    <cc1:LabeledTextBox ID="Password" runat="server" TextMode="Password" Required="true" LabelText="Password" LabelWidth="120" ControlWidth="150" LabelCss="FormLabelText BoldText" ValidationGroup="Standard"></cc1:LabeledTextBox>
                                    <div style="margin-top: 5px; margin-right: 20px; text-align: center;">
                                        <asp:Button ID="btnLogin" runat="server" Text="Log In" CssClass="grnbutton" OnClick="btnLogin_Click" ValidationGroup="Standard" />

I'm trying to set focus on User Name field in the page load.

I have tried

var txtUserName = uxStandardTab.FindControl("UserName");
        if (txtUserName != null)



But, none of them puts cursor in User Name Text box during page load. Please advise, if Tab Control behaves differently.


With Ajax don't use Page.SetFocus but Scriptmanager.SetFocus:


Need Your Help

Recursive array method returning 0 in Java

java arrays matrix

I have taken the tip I got from my last question and went deep into debugging my code. I'm still trying to make a method that takes two multidimensional arrays n*n and multiplies them, as if they w...

dealing with nested quotes in html generated from c#

c# html formatting quotes

i am using a 3rd party library to show tooltips, like so: