This is a migrated thread and some comments may be shown as answers.

Load on Demand working sample

3 Answers 246 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Scott MacDonald
Top achievements
Rank 1
Scott MacDonald asked on 30 Dec 2008, 05:49 PM
I created my application primarially from the Telrik site from a Load on Demand TabStrip sample. I simply would like to incorporate this logic as part of my appliction, but have found an error. The logic works fine when you first click on the tab, but when you re-click a tab you get an error message "Multiple Controls with the same id 'xxxxxx' were found. FindControl requires that the control have unique IDs". In reviewing the trace, I see that the "OnPageViewCreated" control is called when first clicked and then called again as it goes through the logic. Anyone have any thoughts on what is wrong here?
Thank you

********************

 

 

 

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 Jan 2009, 01:39 PM
Hi Scott MacDonald,

This error occurs if you add the same control twice to the control tree. The PageViewCreated event is fired whenever a new PageView object is added - you need to populate the controls inside the PageViewCreated event.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Scott MacDonald
Top achievements
Rank 1
answered on 02 Jan 2009, 04:57 PM

Thank you Albert for your response,
I am still confused however, my logic seems to follow the online sample, what specifically is missing or is in the wrong place?
****************************

ASPX

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="C_Test.aspx.vb" Inherits="SMARTmig.C_Test" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>C Test</title>
    <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR" />
    <meta content="Visual Basic 7.0" name="CODE_LANGUAGE" />
    <meta content="JavaScript" name="vs_defaultClientScript" />
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema" />
</head>
<body>
    <form id="form1" method="post" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server">
            <table cellspacing="0" cellpadding="15" width="100%" border="0">
                <tr>
                    <td bgcolor="#f3f3f3">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor="#f3f3f3">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor="#f3f3f3">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor="#f3f3f3">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor="#f3f3f3">
                        <asp:Image runat="server" ID="LoadingImage1" ImageUrl="../images/loading.gif" AlternateText="Loading..." />
                    </td>
                </tr>
            </table>
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadTabStrip1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                        <telerik:AjaxUpdatedControl ControlID="RadMultiPage1" LoadingPanelID="LoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadMultiPage1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadMultiPage1" LoadingPanelID="LoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <script type="text/javascript">
           
            function onTabSelecting(sender, args)
            {
                if (args.get_tab().get_pageViewID())
                {
                    args.get_tab().set_postBack(false);
                }
            }
           
        </script>

        <table cellspacing="0" cellpadding="15" width="100%" border="0">
            <tr>
                <td bgcolor="#f3f3f3">
                    <font face="Arial, Helvetica, sans-serif" color="#732928" size="2"><strong>Click the
                        tabs below for further details on each phase of the SMART process.</strong></font></td>
            </tr>
        </table>
        <table cellspacing="0" cellpadding="15" width="100%" border="0">
            <tr>
                <td bgcolor="#f3f3f3" colspan="2">
                    <telerik:RadTabStrip Visible="true" OnClientTabSelecting="onTabSelecting" ID="RadTabStrip1"
                        SelectedIndex="2" runat="server" MultiPageID="RadMultiPage1" Skin="Gray" Align="Justify"
                        Width="800px" Orientation="HorizontalTop">
                        <Tabs>
                            <telerik:RadTab Text="Assessment">
                            </telerik:RadTab>
                            <telerik:RadTab Text="Definition">
                            </telerik:RadTab>
                            <telerik:RadTab Text="Validation">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage Visible="true" ID="RadMultiPage1" runat="server" SelectedIndex="0"
                        CssClass="MultiPage" Width="800px" OnPageViewCreated="RadMultiPage1_PageViewCreated">
                    </telerik:RadMultiPage>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

VB.NET

Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Imports Microsoft.VisualBasic

Namespace SMARTmig
  Partial Class C_Test
    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Protected Sub RadTabStrip1_TabClick(ByVal sender As Object, ByVal e As RadTabStripEventArgs) Handles RadTabStrip1.TabClick
      AddPageView(e.Tab.Text)
      e.Tab.PageView.Selected = True
    End Sub

    Private Sub AddPageView(ByVal pageViewID As String)
      Dim pageView As New RadPageView()
      pageView.ID = pageViewID
      RadMultiPage1.PageViews.Add(pageView)
    End Sub

    Protected Sub RadMultiPage1_PageViewCreated(ByVal sender As Object, ByVal e As RadMultiPageEventArgs)
      Dim pageView As New RadPageView()
      Dim userControlName As String = e.PageView.ID + "VB.ascx"
      Dim userControl As Control = Page.LoadControl(userControlName)
      userControl.ID = e.PageView.ID + "_userControl"
      e.PageView.Controls.Add(userControl)
    End Sub

  End Class

End Namespace

ASCX

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="AssessmentVB.ascx.vb" Inherits="Admin_AssessmentVB" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
                            <table cellspacing="0" cellpadding="15" width="100%" border="1">
                                <tr>
                                    <td bgcolor="#f3f3f3">
                                        <img href="#" alt="" src="../images/org_assess_bckgrd.gif" /><br />
                                        <br />
                                        <font face="Arial, Helvetica, sans-serif" color="#732928" size="2"><strong>Assessment!</strong><br />
                                            <br />
                                            <strong>When to position SMART for your clients:</strong><ul>
                                                <li>They are looking for a role based assessment to control what skills are being assessed
                                                    and by whom.</li>
                                                <li>They want to align skills to business needs and direction.</li>
                                            </ul>
                                        </font>&nbsp;
                                    </td>
                                </tr>
                            </table>

0
Paul
Telerik team
answered on 10 Jan 2009, 01:41 PM
Hi Scott MacDonald,

Please find below a slightly modified version of the JS function that should do the trick.

<script type="text/javascript"
function onTabSelecting(sender, args) 
    if (args.get_tab().get_pageView()) 
    { 
        if(args.get_tab().get_pageView().get_id()) 
        { 
            args.get_tab().set_postBack(false); 
        } 
    } 
}             
</script> 


Kind regards,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TabStrip
Asked by
Scott MacDonald
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Scott MacDonald
Top achievements
Rank 1
Paul
Telerik team
Share this question
or