data validation on tab control

Last post 09-09-2009 1:22 PM by panwt. 6 replies.

Sort Posts:

  • data validation on tab control

    10-22-2008, 11:07 AM
    • Member
      54 point Member
    • panwt
    • Member since 03-12-2003, 3:08 PM
    • Posts 16

    How can I put asp.net validation control in the ajax tab control? Need your help!

    Thanks in advance!

  • Re: data validation on tab control

    10-24-2008, 1:07 AM
    Answer
    Hi panwt
     
    To use the ASP.NET Validators in the TabContainer, just drag and drop the Validators into the TabPanel, and the following steps is same to the common way.
     
    Please try the following demo, which works fine on our lab:
      
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="422px"
                Width="733px">
                <cc1:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
                    <ContentTemplate>
                        <asp:Button ID="Button1" runat="server" Text="Button" />
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                    </ContentTemplate>
                </cc1:TabPanel>
                <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
                    <ContentTemplate>
                        <asp:Button ID="Button2" runat="server" Text="Button" />
                    </ContentTemplate>
                </cc1:TabPanel>
                <cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3">
                    <ContentTemplate>
                        <asp:Button ID="Button3" runat="server" Text="Button" />
                    </ContentTemplate>
                </cc1:TabPanel>
            </cc1:TabContainer>
        </div>
        </form>
    </body>
    </html>
    
     

    If I’ve misunderstood the facing issue, please feel free to let me know.
     
    Thanks.
     

     

    Lance Zhang
  • Re: data validation on tab control

    10-24-2008, 3:48 PM
    • Member
      54 point Member
    • panwt
    • Member since 03-12-2003, 3:08 PM
    • Posts 16

    Hi Lance,

    Sorry, my question maybe not correct. It should be how I can validate the data between the tab navigation using asp.net validation control. I only found one solution form the web, here is the link: http://www.bennedik.de/2008/09/validation-in-aspnet-ajax-control.html 

    Is there any better way other than that?

    Thank you very much for your help!

  • Re: data validation on tab control

    10-27-2008, 1:18 AM

    Hi panwt


     

    As your post, I think the solution which provided by Martin Bennedik is very good, you can use Validation Group, just as Vince Xu’s post here: http://forums.asp.net/t/1308716.aspx#2577619


     

    Thanks.


     

    Lance Zhang
  • Re: data validation on tab control

    10-27-2008, 2:10 PM
    • Member
      54 point Member
    • panwt
    • Member since 03-12-2003, 3:08 PM
    • Posts 16

    Thank you, Lance!

  • Re: data validation on tab control

    09-09-2009, 8:10 AM
    • Member
      4 point Member
    • Linz
    • Member since 09-09-2009, 12:06 PM
    • Posts 5

    I have gone through http://www.bennedik.de/2008/09/validation-in-aspnet-ajax-control.html. Good article but it didn't solve my problem though.

     

    what if the user decides to click on the tabs instead of the buttons to navigate back and forth. How do I validate in that case?

     

    Thanks in advance

  • Re: data validation on tab control

    09-09-2009, 1:22 PM
    • Member
      54 point Member
    • panwt
    • Member since 03-12-2003, 3:08 PM
    • Posts 16

    Then you can use case 1 in the article to do the validation for all pages when you click the save button that you have to (must) put it out side of tab control.

Page 1 of 1 (7 items)