troubleshooting Question

Validate textbox inside Ajax:TabContainer using ControlToValidate

Avatar of webressurs
webressursFlag for Norway asked on
8 Comments1 Solution2065 ViewsLast Modified:
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" />

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros