Need to set RadTabStrip TabClick

13 posts, 1 answers
  1. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 25 Jun 2009 Link to this post

    Greetings,

    I have a control called CCMNav.ascx, which contains a RadTabStrip.  There are 4 tabs within it, with each pointing at a different page.  I also have a MasterPage, CCMMaster.Master, which is where I placed CCMNav.ascx in to a ContentPlaceholder (cphContent1).  I then have another ContentPlaceholder (cphContent2), which is where the four pages are to be displayed.  The problem is, I need to add a TabClick event to the RadTabStrip so that when I select a tab, it calls up a method that will save the data to a Session variable.  Here is what I have thus far.

    private void SetTabClickEvents()  
            {  
                ContentPlaceHolder con = (ContentPlaceHolder) Master.Master.FindControl("cphContent1");  
     
                if (con != null)  
                {  
                    CCMNav nav = (CCMNav) con.FindControl("CCMNav");  
     
                    if (nav != null)  
                    {  
                        RadTabStrip tabs = (RadTabStrip) nav.FindControl("radCCMNav");  
     
                        if (tabs != null)  
                        {  
                            tabs.TabClick += SendCoPObjectToSession;  
     
                            //RadTab configurationTab = (RadTab) tabs.FindTabByText("Configuration");  
                            //RadTab displayTab = (RadTab) tabs.FindTabByText("Display");  
                            //RadTab knowareaTab = (RadTab) tabs.FindTabByText("Knowledge Areas");  
                            //RadTab modulesTab = (RadTab) tabs.FindTabByText("Modules");  
                        }  
                    }  
                }  
            } 

    This method is called during the Page_Load event.  Right now, it traces all the way in and does seemingly add the TabClick.  The problem is, when I click the tab, nothing happens.  The event is never fired.  Does anyone have any ideas?  I would be most appreciative if you do.  Thank you.

    ~Chad Johnson
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 26 Jun 2009 Link to this post

    Hi Chad Johnson,

    You should check if you are always subscribing to the TabClick event. It will not work if you subscribe only on initial load (!Page.IsPostBack)

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 26 Jun 2009 Link to this post

    Here is what I have in the Page_Load.

    protected void Page_Load(object sender, EventArgs e)  
    {  
        SetTabClickEvents();  

    This gets called, for I've traced through it, but when I click the tab, nothing still happens.  I'm at a loss to why it would not fire.
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 26 Jun 2009 Link to this post

    Hello Chad Johnson,

    Please trace with the debugger whether this line
         tabs.TabClick += SendCoPObjectToSession; 

    gets executed after postback.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 26 Jun 2009 Link to this post

    The line is reached during Postback and non-Postback, so long as I am still on the page.  However, when I click one of the tabs, nothing is called.
  6. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 26 Jun 2009 Link to this post

    Hello Chad Johnson,

    Do you set the NavigateUrl property of the tabs? If yes the TabClick event will never fire as clicking the tabs navigates instead of performing postback.

    If this is not the case I would ask you to open a support ticket and send us your code so we can troubleshoot it.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 26 Jun 2009 Link to this post

    I see, so if I have the NavigateUrl property set, the TabClick can never be fired.  I'll fix that and see what happens.  Thanks.
  8. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 29 Jun 2009 Link to this post

    Hello Chad,

    The NavigateUrl property overrides the AutoPostBack property of the tabstrip and what happens in effect is simple URL page navigation (postback event never fires).

    If you want to fire the postback, you need to remove the NavigateUrl property from the Tabs. If you still want to redirect after postback, move the URL from NavigateUrl property to Value property and use the Value to redirect. Example:


       protected void ReviewRadTabStrip_TabClick(object sender, TabStripEventArgs e)  
        {  
           Page.Response.Redirect(e.Tab.Value);  
        }  


    Regards,
    Paul
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  9. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 29 Jun 2009 Link to this post

    Thank you, both of you.  It was the NavigateUrl that was interfering with my TabClick events.  I now have it working.  Thanks once more.
  10. Parimal Modi
    Parimal Modi avatar
    18 posts
    Member since:
    Aug 2009

    Posted 11 Dec 2009 Link to this post

    Hi,

    I also have the same problem, but I can not use the Value field for redirection, because I've one more field, that needs to be set on Tab click. Is there any other field which can be used to carry this value.


    Parimal Modi
  11. AvastoneTech
    AvastoneTech avatar
    5 posts
    Member since:
    Jul 2006

    Posted 13 Dec 2009 Link to this post

    I have a similar problem, but the NavigateUrl property is not set for any of my tabs. The TabStrip is tied to a MultiPageView control, but I have the TabStrip set to postback on tab click so I can do some other work. When I hover over the tab, I see the URL of the page with "#" on the end down in the browser's status bar. When I click, nothing happens. It never posts back.

    The really strange bit about this is that it had been working. This project is two months along now, and I need to demo it for the client! Now this suddenly stops working!

    Tim
  12. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Dec 2009 Link to this post

    Hi,

    Can you please try to isolate the problem in a small page with static data? Paste here the relevant code so we can try to reproduce it locally. Thanks

    Greetings,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. AvastoneTech
    AvastoneTech avatar
    5 posts
    Member since:
    Jul 2006

    Posted 16 Dec 2009 Link to this post

    Thanks, Veselin.

    I tracked this down to a required field validator in dynamic mode on one of the currently inactive tabs. The tabstrip would not post back, because it was stopping on the validator. I suppose I will need to make that validator static or even switch to serverside validation for that field. Or keep it disabled until the tab click and then use clientside code to enable it. Lots of options.

    Tim
Back to Top