Solved

Populating AJAX Control Toolkit tabs on page load

Posted on 2013-02-06
4
569 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
ID: 38860135
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
ID: 38860212
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
ID: 38864512
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
ID: 38879453
I found the answer elsewhere.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 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