Avatar of webressurs
webressursFlag for Norway

asked on 

Validate textbox inside Ajax:TabContainer using ControlToValidate

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">
        <ContentTemplate> 
 
            <asp:TextBox runat="server" ID="txtUsername" />
            <asp:TextBox runat="server" ID="txtFirstname" />
            <asp:TextBox runat="server" ID="txtLastname" />
           
        </ContentTemplate>
    </Ajax:TabPanel>
    <Ajax:TabPanel runat="server" HeaderText="Plassering" ID="TabAdvanced">
        <ContentTemplate>
 
            //Other controls here
       
        </ContentTemplate>
    </Ajax:TabPanel>
    <Ajax:TabPanel runat="server" HeaderText="Interesser" ID="TabInterests">
        <ContentTemplate>
       
	    //Other controls here
     
        </ContentTemplate>
    </Ajax:TabPanel>
</Ajax:TabContainer>
 
<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

ASP.NETAJAXC#

Avatar of undefined
Last Comment
amar31282
Avatar of amar31282
amar31282
Flag of India image

I think you need to put the RequiredFieldValidator inside the Ajax Tab Panel
Avatar of webressurs
webressurs
Flag of Norway image

ASKER

Hi! I dont think the ValidatorCalloutExtender is solving this problem. It just add anoother way to display the errormessage, still inside the panel. I need to desplay the error message below (outside) the panel...
Avatar of amar31282
amar31282
Flag of India image

these links provide info about how to find the control inside ajax panel and you can implement validator accordingly
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of amar31282
amar31282
Flag of India image

check if it works
<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">
        <ContentTemplate> 
 
            <asp:TextBox runat="server" ID="txtUsername" />
            <asp:TextBox runat="server" ID="txtFirstname" />
            <asp:TextBox runat="server" ID="txtLastname" />
           
        </ContentTemplate>
    </Ajax:TabPanel>
    <Ajax:TabPanel runat="server" HeaderText="Plassering" ID="TabAdvanced">
        <ContentTemplate>
 
            //Other controls here
       
        </ContentTemplate>
    </Ajax:TabPanel>
    <Ajax:TabPanel runat="server" HeaderText="Interesser" ID="TabInterests">
        <ContentTemplate>
       
            //Other controls here
     <asp:Button runat="server" ID="btnSaveUser" OnClick="btnSaveUser_Click" Text="Lagre" CausesValidation="true" />
        </ContentTemplate>
    </Ajax:TabPanel>
</Ajax:TabContainer>
 
<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" />
 

Open in new window

Avatar of amar31282
amar31282
Flag of India image

OOPS i think i am late and did what @prairiedog just explained before me
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo