access tabstrip from usercontrol on tab

11 posts, 1 answers
  1. newbie
    newbie avatar
    355 posts
    Member since:
    Feb 2008

    Posted 12 Jan 2010 Link to this post

    I have a tabstrip on my page with several tabs and each tab has a usercontrol.
    On one of my tabs based on a certain condition, I want to disable the other tabs.

    Can you help me achieve this. I am unable to get a reference to the tabstrip from within the user control. I am using the latest build of ASP.NET AJAX controls.

    Please help.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jan 2010 Link to this post

    Hi,

    Here's an example of how to access the RadTabStrip from within the UserControl nested in its tab:
    ascx.cs:
    protected void Page_Load(object sender, EventArgs e) 
        { 
            UserControl user = (UserControl)sender; 
            RadTabStrip tabstrip = (RadTabStrip)(user.NamingContainer.FindControl("RadTabStrip1")); 
            foreach (RadTab tab in tabstrip.Tabs) 
            { 
                if (//custom condition) 
                { 
                    tab.Enabled = false
                } 
            }       
        } 

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. illumination
    illumination avatar
    85 posts
    Member since:
    May 2008

    Posted 02 Dec 2010 Link to this post

    I have tried to convert the cs code below to vb using telerik converter but it gave me this error:
    CONVERSION ERROR: Code could not be converted. Details:
      
    -- line 1 col 11: invalid TypeDecl
      
    Please check for any errors in the original code and try again.
    Will you provide me with the VB code version please?
    Thank you.
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 08 Dec 2010 Link to this post

    Hi Illumination,

    This is the converted VB code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
        Dim user As UserControl = DirectCast(sender, UserControl)
        Dim tabstrip As RadTabStrip = DirectCast(user.NamingContainer.FindControl("RadTabStrip1"), RadTabStrip)
        For Each tab As RadTab In tabstrip.Tabs
            If ("Custom Condition here") Then
                tab.Enabled = False
            End If
        Next
    End Sub

    All the best,
    Dimitar Terziev
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. illumination
    illumination avatar
    85 posts
    Member since:
    May 2008

    Posted 08 Dec 2010 Link to this post

    I got that working already. Thanks for the reply!
  7. Spyros
    Spyros avatar
    4 posts
    Member since:
    Feb 2013

    Posted 11 May 2013 Link to this post

    Hi,

    Thanks for the solution above t solved half of my problem. The other half of the problem is that I want to enable the tabs from my button click event.How do I achieve that?
  8. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 13 May 2013 Link to this post

    Hi Spyros,

    You can find the RadTabStrip control and use the foreach to go through all the tabs and set their Enable property to true.

    Greetings,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  9. Spyros
    Spyros avatar
    4 posts
    Member since:
    Feb 2013

    Posted 13 May 2013 Link to this post

    That's what I'am doing currently unfortunately ajaxfication prevents me of just looping and enabling the tab. 

    So my next question is how do i achieve this with Ajax?
  10. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 15 May 2013 Link to this post

    Hello Spyros,

    in general when using ajax on your page you can eaily enable/disable any control. Here I prepared a very simplified runnable page demonstrating the approach. When clicking on the second tab there are two buttons for enabling and disabling the tabs of the RadTabStrip control. Of course you can also further extend it to match your requirements.

    Regards,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  11. Spyros
    Spyros avatar
    4 posts
    Member since:
    Feb 2013

    Posted 08 Jun 2013 Link to this post

    Sorry for the late reply Kate and thank you for the sample project. This is not exactly my case. My radtabstrip is inside my aspx page so what I want to do is to enable/disable my tabs directly from my usercontrol but... ajax prevents this. I want to know a way to handle the ajax triggering for a control inside a content page from a child control (usercontrol). I dont know if this makes any sense.
  12. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 13 Jun 2013 Link to this post

    Hello Spyros,

    I would kindly like to ask you to submit a support ticket where you can attach a simplified version of the project that  you are currently using, so I can help you out in your particular scenario. Thus, I would be able to assist you in the most efficient way.

    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017