Solved

Populating AJAX Control Toolkit tabs on page load

Posted on 2013-02-06
4
563 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

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.
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
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…

930 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

13 Experts available now in Live!

Get 1:1 Help Now