We help IT Professionals succeed at work.
Get Started

Validate textbox inside Ajax:TabContainer using ControlToValidate

webressurs asked
Last Modified: 2012-05-06
I have some controls (textboxes) inside different Ajax:TabPanels that I need to validate. Since I validate controls in different panels I have to place the asp:RequiredFieldValidator below the TabContainer. Then the user will see all errormessages from different panels at the same time.

But, the asp:RequiredFieldValidator cant find the controls inside the tab container. How can I use asp:RequiredFieldValidator for controls inside a tab panel? Se attached code.
<asp:ScriptManager ID="ScriptManager" runat="server" />        
<Ajax:TabContainer ID="TabContainer" runat="server" ActiveTabIndex="0" EnableViewState="true" Width="98%">
    <Ajax:TabPanel runat="server" HeaderText="Generelt" ID="TabGeneral">
            <asp:TextBox runat="server" ID="txtUsername" />
            <asp:TextBox runat="server" ID="txtFirstname" />
            <asp:TextBox runat="server" ID="txtLastname" />
    <Ajax:TabPanel runat="server" HeaderText="Plassering" ID="TabAdvanced">
            //Other controls here
    <Ajax:TabPanel runat="server" HeaderText="Interesser" ID="TabInterests">
	    //Other controls here
<asp:RequiredFieldValidator runat="server" ID="reqUsername" Display="Dynamic" ErrorMessage=" -Missing Username" ControlToValidate="txtUsername" />
<asp:RequiredFieldValidator runat="server" ID="reqFirstname" Display="Dynamic" ErrorMessage=" -Missing Firstname" ControlToValidate="txtFirstname" />
<asp:RequiredFieldValidator runat="server" ID="reqLastname" Display="Dynamic" ErrorMessage=" -Missing Lastname" ControlToValidate="txtLastname" />
<asp:Button runat="server" ID="btnSaveUser" OnClick="btnSaveUser_Click" Text="Lagre" CausesValidation="true" />

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE