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

Ajaxifying TabStrips + loading UserCtls into pageviews

1 Answer 164 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 23 May 2008, 01:51 PM

I have up to a point had success in loading UserCtls into my TabStrip pageviews,..however they did not survive postbacks or reload on TabClicks.

The Tabs themselves sit in a User Control which loads fine from the MasterPage (using RadMenu and several asp panes and resolveUpdatedControls  +  unloading reloading etc)
thanks Telerik for getting me that far)
# just one oddity ..goes thru page load twice!..but will ask re that in a differet thread.

This  Problem:
(also goes thru PageLoad twice.?)

Using code from some of the examples .."BuildPageViewContents and "PageViewItemCreated" ..viewsate or session,..The selected user ctl is not being loaded, nor on tab click (server side code which executes)..are the user controls loaded.

Help please,..
attached the code

C#

public

partial class TabbedOBs : System.Web.UI.UserControl

 

{

//Property used to Maintain State of loaded UserContol

 

public string selectedUC

{

set

 

{

Session[

"selectedUC"] = value;

}

get

 

{

return Session["selectedUC"] == null ? "OccurrenceBook.ascx" : Session["selectedUC"].ToString();

}

}

//Property used to Maintain State of pageview

 

public string selectedPV

{

set

 

{

Session[

"selectedPV"] = value;

}

get

 

{

return Session["selectedPV"] == null ? "PageView1" : Session["selectedPV"].ToString();

}

}

 

protected void Page_Load(object sender, EventArgs e)

{

AjaxifySelf();

// first tab is defaulted..showing the OccurrenceBook U.Ctl and its gridded data

 

if (!IsPostBack) //RadMultiPage1_PageViewItemCreated..handles postbacks

 

{

//Sets & Loads the UCtls

 

BindMultiPage(

this.selectedPV);

}

}

private void AjaxifySelf()

{

RadAjaxManager ajaxManager = (RadAjaxManager)Page.FindControl("RadAjaxManager1");

ajaxManager.AjaxSettings.AddAjaxSetting(

this.FindControl("RadTabStrip1"), LoadingPanel1);

}

protected void RadTabStrip1_TabClick(object sender, TabStripEventArgs e)

//This is ajaxified, causes a postback, and PageViewItemCreated handles the uctl re-loads

 

{

Telerik.WebControls.

Tab TabClicked = e.Tab;

if (TabClicked.Value == "Occurrence Book")

{

this.selectedUC = "OccurrenceBook.ascx";

this.selectedPV = "PageView1";

}

else

 

{

this.selectedUC = "UserLogs.ascx";

this.selectedPV = "PageView1";

}

}

private void BindMultiPage()

{

PageView pv = new PageView();

//pageview which is to have it's contents built/loaded

 

pv.ID =

this.selectedPV;

BuildPageViewContents(pv, 0);

}

 

#region

Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

 

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

 

//

 

InitializeComponent();

base.OnInit(e);

}

/// <summary>

 

/// Required method for Designer support - do not modify

 

/// the contents of this method with the code editor.

 

/// </summary>

 

private void InitializeComponent()

{

this.RadMultiPage1.PageViewItemCreated += new PageViewItemCreatedDelegate(this.RadMultiPage1_PageViewItemCreated);

this.Load += new System.EventHandler(this.Page_Load);

}

 

#endregion

 

 

//the PageViewItemCreated event is used to restore the dynamic pageview..

 

//ON POSTBACK...i.e. recreate any/all controls on postback

 

private void RadMultiPage1_PageViewItemCreated(PageView view, int viewIndex)

{

BuildPageViewContents(PageView1, viewIndex);

}

 

private void BuildPageViewContents(PageView pageView, int index)

{

//Load the selected UserControl (default or by TabClicked)

 

Control control = this.LoadControl(this.selectedUC);

string uniqueID = this.selectedUC.Split('.')[0];

uniqueID = uniqueID.Replace(

"/", "").Replace("~", "");

control.ID = uniqueID;

//Load control into Required PageView

 

//...AND prevent controls from being loaded twice.....weird !!,..

 

if (pageView.FindControl(control.ID) == null)

{

pageView.Controls.Add(control);

}

}

 

}

 

aspx

<

radTS:RadTabStrip ID="RadTabStrip1"

runat="server"

MultiPageID="RadMultiPage1"

OnTabClick="RadTabStrip1_TabClick" >

<Tabs>

<radTS:Tab runat="server" Text="Occurrence Book" Value="Tab1" >

</radTS:Tab>

<radTS:Tab runat="server" Text="User Logs" Value="Tab2">

</radTS:Tab>

</Tabs>

</

radTS:RadTabStrip>

<

radTS:RadMultiPage ID="RadMultiPage1" runat="server">

<radTS:PageView ID="PageView1" runat="server">

Operations

</radTS:PageView>

<radTS:PageView ID="PageView2" runat="server">

UserLogs

</radTS:PageView>

</

radTS:RadMultiPage>

<

rada:AjaxLoadingPanel id="LoadingPanel1" Runat="server"

Transparency="30" BackColor="#E0E0E0">

<asp:Image id="Image1" runat="server" AlternateText="Loading..."

BorderWidth="0px" ImageUrl="~/RadControls/AJAX/Skins/Default/loading.gif"></asp:Image>

</

rada:AjaxLoadingPanel>



1 Answer, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 28 May 2008, 11:04 AM
Hello Neal,

For details on the matter please refer to our Dynamic RadPageView online example. In the code tabs below the example you can find the code used.

Sincerely yours,
Paul
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TabStrip
Asked by
Neal
Top achievements
Rank 1
Answers by
Paul
Telerik team
Share this question
or