Hi ,
I have a RadTabStrip which is to generate tab dynamically . Each tab load same usercontrol but with different data . My issue is that When the tab is created for first time it loads the data but when I toggle to earlier tab , the data reflected is of last created tab . This is basically due to creation of RadMultiPage having same id .
How to overcome this issue .
My code are as follow ..
<asp:Content ID="Content1" ContentPlaceHolderID="FormPlaceHolder" runat="server">
<telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1" Skin="Metro">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerMpInfo" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadTabStrip1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadTabStrip1"></telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="RadMultiPage1" LoadingPanelID="LoadingPanel1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadMultiPage1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadMultiPage1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<script type="text/javascript">
/* <![CDATA[ */
function onTabSelecting(sender, args) {
if (args.get_tab().get_pageViewID()) {
args.get_tab().set_postBack(false);
}
}
/* ]]> */
</script>
<telerik:RadTabStrip OnClientTabSelecting="onTabSelecting" ID="RadTabStrip1" SelectedIndex="0"
runat="server" MultiPageID="RadMultiPage1" Skin="Windows7" Width="100%" Align="Justify"
OnTabClick="RadTabStrip1_TabClick">
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated">
</telerik:RadMultiPage>
</asp:Content>
CodeBehind cs file is ..
if (!Page.IsPostBack)
{
try
{
if(mpCollection.Count() > 0 && this.Master.IdProgram.HasValue)
{
// AddTab("ΣMPs");
using (Context idcardContext = new Context())
{
foreach (string mp in mpCollection)
{
MP currentMp = MPTestBusiness.GetMPById(idcardContext, Int32.Parse(mp));
mpListCollection.Add(currentMp);
AddTab(currentMp);
}
AddPageView(RadTabStrip1.FindTabByText(mpListCollection[0].Code));
}
}
}
catch (Exception ex)
{
Log.Error(ex);
this.Master.DisplayErrorAlert(MessageConstants.GenericError);
}
private void AddTab(MP mp)
{
RadTab tab = new RadTab();
tab.Text = mp.Code;
RadTabStrip1.Tabs.Add(tab);
}
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
string userControlName = "../UserControl/MPInfoControl.ascx";
Control userControl = Page.LoadControl(userControlName);
userControl.ID = "userControl_" + e.PageView.ID;
if(!e.PageView.Controls.Contains(userControl))
e.PageView.Controls.Add(userControl);
}
private void AddPageView(RadTab tab)
{
if(tab != null)
{
RadPageView pageView = new RadPageView();
pageView.ID = tab.Text;
tab.PageViewID = pageView.ID;
RadMultiPage1.PageViews.Add(pageView);
}
}
protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
{
if (e.Tab != null)
{
AddPageView(e.Tab);
e.Tab.PageView.Selected = true;
}
}
I have followed the following demo
https://demos.telerik.com/aspnet-ajax/tabstrip/examples/multipage/dynamic-pageview-creation/defaultcs.aspx
however here different usercontrol has been used for loading in different tab but in my case same usercontrol has to be loaded . Going further I will be adding another user control for specific values .