Solved

Populating AJAX Control Toolkit tabs on page load

Posted on 2013-02-06
4
557 Views
Last Modified: 2013-02-12
I'm trying to use the tab functionality provided through the AJAX Control Toolkit to show different views of data, which is being pulled through a WCF service from our database.  Because of some cross-domain issues, I need to access this service from the server side through C# rather than from the client side through Javascript.  As such, I'm trying to load this data during the page load event.  

Here is the asp.net code:
<asp:Panel runat="server" ID="_pnlMain">
    <AJAXToolkit:TabContainer ID="_tabViewTabs" runat="server">
        <AJAXToolkit:TabPanel runat="server" ID="_tplView1" HeaderText="Tab 1">
            <ContentTemplate>
                <div runat="server" id="_div1"></div>
            </ContentTemplate>
        </AJAXToolkit:TabPanel>

        <AJAXToolkit:TabPanel runat="server" ID="_tplView2" HeaderText="Tab 2">
            <ContentTemplate>
                <div runat="server" id="_div2"></div>
            </ContentTemplate>
        </AJAXToolkit:TabPanel>
    </AJAXToolkit:TabContainer>
</asp:Panel>

In page load, I'm building a table, which I'm then adding to the _div1 control:
System.Web.UI.Control selectedControl = FindControl(controlID);
selectedControl.Controls.Add(tbl);

However, whenever I try to access the _div1 component, I get a message saying that the control cannot be found.  If I move the _div1 component outside of the tab container, I can access it just fine.  I'm taking this to mean that the tab container elements haven't fully loaded at the time when I'm running the script, and that it therefore doesn't exist yet.  The same thing happens if I try to run this code in the Pre-Render or Render methods.  I also tried the Page.LoadComplete method, but this won't work because the code is inside a SharePoint User Control.

Is there any way to run this code after the AJAX tab container has already loaded?
0
Comment
Question by:MSEC
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Steve Krile
Comment Utility
A bit sideways to your question, but what about setting up a service on your site that handles the cross-domain problem - then call that service from the client side as you suggest at the beginning of your post that you'd prefer to do?
0
 

Author Comment

by:MSEC
Comment Utility
Because I have to integrate with a third party vendor through this same service, the service uses XML & Ajax, rather than JSON.  As such, it's difficult to handle the cross-domain problem.
0
 

Accepted Solution

by:
MSEC earned 0 total points
Comment Utility
I actually figured this out.  The problem wasn't that it was running on page load.  The problem was that the control was nested within other controls.  Here's how I had to change FindControl to make this work:
FindControl("tabContainer").FindControl("tab").FindControl("control");
0
 

Author Closing Comment

by:MSEC
Comment Utility
I found the answer elsewhere.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now