TabStrip server validation.

2 posts, 1 answers
  1. Silvio Silva Junior
    Silvio Silva Junior avatar
    100 posts
    Member since:
    Mar 2010

    Posted 22 Apr 2010 Link to this post

    Hello guys.

    In tabclick event how can I refuse to change tabs, based in a condition?

    Regards.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Apr 2010 Link to this post

    Hello Silvio,

    I guess you can accomplish the functionality by adding CustomValidator on page and check for the condition in the 'ServerValidate' event. Here is the code snippet that I tried for similar scenario.

    ASPX:

     
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" AutoPostBack="True" OnTabClick="RadTabStrip1_TabClick"  
        SelectedIndex="1" CausesValidation="True" ValidationGroup="LoginValidationGroup">  
        <Tabs>  
          . . .  
        </Tabs>  
    </telerik:RadTabStrip>  
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"  
        ValidationGroup="LoginValidationGroup" OnServerValidate="CustomValidator1_ServerValidate">  
    </asp:CustomValidator> 

    C#:

     
        protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)  
        {  
            if (Page.IsValid)  
            {  
                Response.Write("Valid");  
            }  
        }  
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)  
        {  
            if (TextBox1.Text == ""// Cehck for condition here  
            {  
                args.IsValid = false;  
            }  
        } 

    -Shinu.

Back to Top