Solved

Populating AJAX Control Toolkit tabs on page load

Posted on 2013-02-06
4
572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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