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

PageViewCreated doesn't fire

2 Answers 67 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Denise
Top achievements
Rank 1
Denise asked on 07 Nov 2012, 09:37 PM

Hi all,

I'm having a problem with PageViewCreated either not firing at all or firing too often.  My markup is this:

<telerik:RadTabStrip ID="rtsReturns" runat="server" MultiPageID="rmpReturns" OnTabClick="rtsReturns_TabClick">
     <Tabs>
         <telerik:RadTab runat="server" Text="Current Returns" Value="Current"></telerik:RadTab>
     </Tabs>
 </telerik:RadTabStrip>
  <telerik:RadMultiPage id="rmpReturns" runat="server" SelectedIndex="0" Width="400">
   <telerik:RadPageView id="pgvwCurrent" runat="server">
       <h1>This is where the current returns will go</h1>
   </telerik:RadPageView>
 </telerik:RadMultiPage>

And my codebehind is:

protected void Page_PreRender(object sender, EventArgs e)
{
  if (!IsPostBack)
  {
    foreach (TrustTaxReturnGroup ttrg in Ctl.FormerTTRGs)
    {
      RadTab tab1 = new RadTab(ttrg.StartDate.ToString());
      tab1.Value = ttrg.StartDate.ToString();
      rtsReturns.Tabs.Add(tab1);
 
      RadPageView pg1 = new RadPageView();
      pg1.ID = ttrg.StartDate.ToString();
      rmpReturns.PageViews.Add(pg1);
    }
  }
}

and

protected void rmpReturns_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
  RadTextBox tb = new RadTextBox();
  tb.Text = "This should be on the page just created";
  tb.ID = e.PageView.ID + "_textbox";
  e.PageView.Controls.Add(tb);
}

If I modify the markup to include

OnPageViewCreated="rmpReturns_PageViewCreated"

the PageViewCreated method fires three times every time I click a tab (since there are three tabs being created programatically).  But if I don't have that in my markup it never enters that routine at all.  I thought maybe it had something to do with the pageviews being created in the PreRender but I moved it to the Page_OnLoad and the results are the same. 

I'm sure it's something I'm just not seeing, but I'm just not seeing it.  Can anyone out there set me straight?  I'd greatly appreciate it.

2 Answers, 1 is accepted

Sort by
0
Denise
Top achievements
Rank 1
answered on 09 Nov 2012, 06:43 PM
Found the problem..... the code was in the page PreRender.  Once I moved it to PageLoad it worked.  I'd forgotten the lifecycle and that I could act upon previously created objects in the PreRender (thus the tabs got added) but not create new objects in there (thus the textboxes weren't getting placed in the pageview).
0
Nencho
Telerik team
answered on 12 Nov 2012, 04:11 PM
Hello Denise,

I am glad to see, that the problem you were facing is now resolved.

Greetings,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TabStrip
Asked by
Denise
Top achievements
Rank 1
Answers by
Denise
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or