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);
}
}
}