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

Multipage on demand with post back not working

1 Answer 108 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
ajay
Top achievements
Rank 1
ajay asked on 10 Feb 2015, 06:46 AM
Hi Telerik forum,
I am trying to implement ondemand property of Radmultipage using the http://demos.telerik.com/aspnet-ajax/tabstrip/examples/multipage/dynamic-pageview-creation/defaultcs.aspx. It is working some how. But what i need is i want to postback on each time when tab clicked .
For this i removed clientFunction called "onClientTabselecting".

This is where i am facing the problem. I am getting the error "Multiple controls with same ID found...." . And in my two of my viewpages contain user controls
I am getting the respective error only on re-clicking on the tab which contain user control.

 My design:
  
<telerik:RadTabStrip ID="Vehicles" runat="server" Skin="Metro" MultiPageID="RadMultiPage1" 
                       SelectedIndex="0" Width="99%" OnTabClick="Vehicles_TabClick" 
                       AutoPostBack="true">
      
        <telerik:RadTab Text="Cars"  PageViewID="radCars" Value="radTabCars"> </telerik:RadTab>
        <telerik:RadTab Text="Train"   Value="radTabTrain">  </telerik:RadTab>                  
        <telerik:RadTab Text="Bus" CssClass="CustomTab"  HoveredCssClass="HoveredTab"
                              Value="radTabBus">
                          </telerik:RadTab>
       <telerik:RadTab Text="Cycle"  Value="radTabCycle" > </telerik:RadTab>
 
       <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated"
                        EnableViewState="true">
 
       <telerik:RadPageView ID="radPVCars" runat="server">
            <telerik:RadGrid ID="grdCars" runat="server" AllowSorting="true" </telerik:RadGrid>
       </telerik:RagpageView>
        <telerik:RadPageView ID="radPVTrain" runat="server">
          <DManagement:Fax runat="server" ID="UCTrain" Status="Train" />
        </telerik:RagpageView>
        <telerik:RadPageView ID="radPVBus" runat="server">
              <DManagement:Fax runat="server" ID="UCcyvle" Status="Bus" />
         </telerik:RagpageView>
       <telerik:RadPageView ID="radPVCycle" runat="server">
 
       <telerik:RadGrid ID="grdCycle" runat="server" AllowSorting="true" </telerik:RadGrid>
       </telerik:RagpageView>

                               

 Code behind:

      
protected void Vehicles_TabClick(object sender, RadTabStripEventArgs e)
        {
             
            AddPageView(e.Tab);
          
            e.Tab.PageView.Selected = true;
        }
   
 
     private void AddPageView(RadTab tab)
        {
            RadPageView pageView = new RadPageView();
            if (tab.Value == "radTabCars")
            {
                RadMultiPage1.SelectedIndex = RadMultiPage1.FindPageViewByID("radPVCars").Index;
                tab.PageViewID = "radPVCars";
                
 
                return;
            }
            else if (tab.Value == "radTabCycle")
            {
                RadMultiPage1.SelectedIndex = RadMultiPage1.FindPageViewByID("radPVCycle").Index;
                tab.PageViewID = "radPVCycle";
                
 
                return;
            }
            
 
            
            switch (tab.Value)
            {
                case "radTabTrain":
                    pageView.ID = "radPVTrain";
                    break;
                case "radTabBus":
                    pageView.ID = "radPVBus";
                    break;
                
            }
            
            RadMultiPage1.PageViews.Add(pageView);
            RadMultiPage1.SelectedIndex = RadMultiPage1.PageViews.Count - 1;
            tab.PageViewID = pageView.ID;
            
        }
 
 
      protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            string uControlName = "";
            string uControlId = "";
             switch (e.PageView.ID)
            {
                case "radPVTrain":
                    uControlName = "~/USC/UserControls/Dgmt_vehicle.ascx";
                    userControlId = "VehTrain";
                    break;
                case "radPVBus":
                    uControlName = "~/USC/UserControls/Dgmt_vehicle.ascx";
                    userControlId = "VehBus";
                    break;
            }
            Control userControl1 = Page.LoadControl(userControlName);
            UserControls.Dgmt_Faxes objControl = (UserControls.Dgmt_Faxes)userControl1;
              
             if (uControlId  == "VehTrain")
                objControl.Status = "Train";
            else if (uControlId  == "VehBus")
                objControl.Status = "Bus";
             
            userControl = (VehicleUserControl)userControl1;
            userControl.ID = userControlId;
            e.PageView.Controls.Add(userControl);
            e.PageView.EnableViewState = true;
            
 
        }
             

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 13 Feb 2015, 07:16 AM
Hi,

The error you describe is usually observed when the ID of two or more controls on the page are duplicated. Please check the ID of the controls in both User Controls and ensure that there are no duplicates.

Also, you can make the RadMultiPage render only one page at a time. For this you need to set the RenderSelectedPageOnly to true.


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Ajax
Asked by
ajay
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or