Tabstrip as a wizard

13 posts, 0 answers
  1. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 11 Jun 2014 Link to this post

    Hi,

    I am using tabstrip as a wizard.

    I have previous and next buttons on my page and I load a user control in the multipage for each tabstrip.
    When I navigate with the previous button. I have some binding controls on my pages which get bound when i pass the data for that particular tab.
    WHen I am using the previous button it is trying to render all the tabs. SInce I don't pass data for all the tabs my code is not able to bind some controls.
    Below is my code and html.

    Let me know what am I doing wrong. I suspect I am not using the LoadStep() function call at the right place but I am not able to figure out the right event.

    <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td>
                    <telerik:RadTabStrip ID="rtsEnrollment" runat="server" MultiPageID="rmpEnrollment"
                        OnTabClick="rtsEnrollment_TabClick" SelectedIndex="0" CausesValidation="true"
                        Align="Justify" AutoPostBack="true">
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage ID="rmpEnrollment" runat="server" SelectedIndex="0" OnPageViewCreated="rmpEnrollment_PageViewCreated"
                        CssClass="multiPage">
                    </telerik:RadMultiPage>
                </td>
            </tr>
           <tr>
                <td class="enrollmentButton">
                    <telerik:RadButton runat="server" ID="PreviousButton" Text="<< Previous" OnClick="PreviousButton_Click"
                        AutoPostBack="true" CausesValidation="false">
                    </telerik:RadButton>
                    <telerik:RadButton runat="server" ID="ContinueButton" Text="Next >>" CausesValidation="true"
                        AutoPostBack="true" OnClick="ContinueButton_Click">
                    </telerik:RadButton>
                </td>
            </tr>
        </table>

    public partial class enrollment_theCompany_EDCP : EnrollmentBasePage
    {
        protected void LoadStep()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
            RadTab tab = rtsEnrollment.FindTabByText(tabName);
     
            switch (rtsEnrollment.SelectedTab.Text)
            {
                case "Deferral Elections":
                    LoadSalaryElections(tab);
                    break;
     
                case "Distribution Elections":
                    LoadDistributionElections(tab);
                    break;
     
                case "Fund Allocations":
                    RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                    ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                    ucFundAllocations.LoadPlan();
                    break;
     
                case "Enrollment Summary":
                    // commit data
                    RadPageView pvEnrollmentSummary = (RadPageView)tab.PageView.FindControl("enrollmentSummary");
                    enrollment_ucEnrollmentSummary ucEnrollmentSummary = (enrollment_ucEnrollmentSummary)pvEnrollmentSummary.FindControl("ucEnrollmentSummary");
                    _enrollment.CommitEnrollmentData(DeferralSources());
                    break;
            }
        }
     
        protected override void UpdateStep(int nextStepIndex)
        {       
                string tabName = rtsEnrollment.SelectedTab.Text;
                RadTab tab = rtsEnrollment.FindTabByText(tabName);
                switch (tabName)
                {
                    case "Deferral Elections":
                        RadPageView pvDeferralElections = (RadPageView)tab.PageView.FindControl("deferralElections");
                        enrollment_theCompany_deferralElections ucDeferralElections = (enrollment_theCompany_deferralElections)pvDeferralElections.FindControl("ucDeferralElections");
                        ucDeferralElections.SaveForEnrollment(_enrollment);
                        break;
     
                    case "Distribution Elections":
                        RadPageView pvPaymentOptions = (RadPageView)tab.PageView.FindControl("paymentOptions");
                        enrollment_theCompany_paymentOptions ucPaymentOptions = (enrollment_theCompany_paymentOptions)pvPaymentOptions.FindControl("ucPaymentOptions");
                        ucPaymentOptions.PlanPeriodName = _enrollment.PlanPeriodName;
                        ucPaymentOptions.SaveForEnrollment(_enrollment);
                        break;
     
                    case "Fund Allocations":
                        RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                        ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                        ucFundAllocations.SaveAllocationForEnrollment(_enrollment);
                        break;
     
                    case "Enrollment Summary":
                        break;
                }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AddTab("Deferral Elections", true);
     
                RadPageView pageView = new RadPageView();
                pageView.ID = "DeferralElections";
                rmpEnrollment.PageViews.Add(pageView);
     
                AddTab("Distribution Elections", false);
                AddTab("Fund Allocations", false);
                AddTab("Enrollment Summary", false);
     
                LoadStep();
            }
        }
     
        #region UI Events
     
        protected void rmpEnrollment_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            Control pageViewContents = new Control();
            switch (e.PageView.ID)
            {
                case "DeferralElections":
                    pageViewContents = LoadControl("~/enrollment/thecompany/deferralElections.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID ;
                    break;
                case "PaymentOptions":
                    pageViewContents = LoadControl("~/enrollment/thecompany/paymentOptions.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
                case "FundAllocations":
                    pageViewContents = LoadControl("~/fund/ucFundbucket.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
                case "EnrollmentSummary":
                    pageViewContents = LoadControl("~/enrollment/ucEnrollmentSummary.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
            }
     
            e.PageView.Controls.Add(pageViewContents);
        }
     
        protected void PreviousButton_Click(object sender, EventArgs e)
        {
            GoToPreviousTab();
            GoToPreviousPageView();
            LoadStep();        
        }
     
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            UpdateStep();       
            GoToNextTab();
            GoToNextPageView();
            LoadStep();        
        }
         
        #endregion
     
        #region Private Events
         
        private void GoToNextTab()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    RadTab paymentOptionsTab = rtsEnrollment.FindTabByText("Distribution Elections");
                    rtsEnrollment.ValidationGroup = "PaymentOptionsTabValidationGroup";
                    paymentOptionsTab.Enabled = true;
                    paymentOptionsTab.Selected = true;
                    break;
     
                case "Distribution Elections":
                    RadTab fundAllocationsTab = rtsEnrollment.FindTabByText("Fund Allocations");
                    fundAllocationsTab.Enabled = true;
                    fundAllocationsTab.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadTab enrollmentSummaryTab = rtsEnrollment.FindTabByText("Enrollment Summary");
                    enrollmentSummaryTab.Enabled = true;
                    enrollmentSummaryTab.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    break;
            }       
        }
     
        private void GoToNextPageView()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    break;
     
                case "Distribution Elections":
                    RadPageView paymentOptionsTabPageView = rmpEnrollment.FindPageViewByID("PaymentOptions");
                    if (paymentOptionsTabPageView == null)
                    {
                        paymentOptionsTabPageView = new RadPageView();
                        paymentOptionsTabPageView.ID = "PaymentOptions";
                        rmpEnrollment.PageViews.Add(paymentOptionsTabPageView);
                    }
                    paymentOptionsTabPageView.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadPageView fundAllocationsTabPageView = rmpEnrollment.FindPageViewByID("FundAllocations");
                    if (fundAllocationsTabPageView == null)
                    {
                        fundAllocationsTabPageView = new RadPageView();
                        fundAllocationsTabPageView.ID = "FundAllocations";
                        rmpEnrollment.PageViews.Add(fundAllocationsTabPageView);
                    }
                    fundAllocationsTabPageView.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    RadPageView enrollmentSummaryTabPageView = rmpEnrollment.FindPageViewByID("EnrollmentSummary");
                    if (enrollmentSummaryTabPageView == null)
                    {
                        enrollmentSummaryTabPageView = new RadPageView();
                        enrollmentSummaryTabPageView.ID = "EnrollmentSummary";
                        rmpEnrollment.PageViews.Add(enrollmentSummaryTabPageView);
                    }
                    enrollmentSummaryTabPageView.Selected = true;
                    break;
            }
        }
     
        private void GoToPreviousTab()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    break;
     
                case "Distribution Elections":
                    RadTab deferralElectionsTab = rtsEnrollment.FindTabByText("Deferral Elections");
                    rtsEnrollment.ValidationGroup = "DeferralElectionsTabValidationGroup";
                    deferralElectionsTab.Enabled = true;
                    deferralElectionsTab.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadTab paymentOptionsTab = rtsEnrollment.FindTabByText("Distribution Elections");
                    rtsEnrollment.ValidationGroup = "PaymentOptionsTabValidationGroup";
                    paymentOptionsTab.Enabled = true;
                    paymentOptionsTab.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    RadTab FundAllocationsTab = rtsEnrollment.FindTabByText("Fund Allocations");
                    FundAllocationsTab.Enabled = true;
                    FundAllocationsTab.Selected = true;
                    break;
            }
        }
     
        private void GoToPreviousPageView()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    RadPageView deferralElectionsTabPageView = rmpEnrollment.FindPageViewByID("DeferralElections");
                    if (deferralElectionsTabPageView == null)
                    {
                        deferralElectionsTabPageView = new RadPageView();
                        deferralElectionsTabPageView.ID = "DeferralElections";
                        rmpEnrollment.PageViews.Add(deferralElectionsTabPageView);
                    }
                    deferralElectionsTabPageView.Selected = true;
                    break;
     
                case "Distribution Elections":
                    RadPageView paymentOptionsTabPageView = rmpEnrollment.FindPageViewByID("PaymentOptions");
                    if (paymentOptionsTabPageView == null)
                    {
                        paymentOptionsTabPageView = new RadPageView();
                        paymentOptionsTabPageView.ID = "PaymentOptions";
                        rmpEnrollment.PageViews.Add(paymentOptionsTabPageView);
                    }
                    paymentOptionsTabPageView.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadPageView fundAllocationsTabPageView = rmpEnrollment.FindPageViewByID("FundAllocations");
                    if (fundAllocationsTabPageView == null)
                    {
                        fundAllocationsTabPageView = new RadPageView();
                        fundAllocationsTabPageView.ID = "FundAllocations";
                        rmpEnrollment.PageViews.Add(fundAllocationsTabPageView);
                    }
                    fundAllocationsTabPageView.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    break;
            }
        }
         
        private void AddTab(string tabName, bool enabled)
        {
            RadTab tab = new RadTab(tabName);
     
            tab.Enabled = enabled;
     
            switch (tab.Text)
            {
                case "Deferral Elections":
                    break;
                case "Distribution Elections":
                    break;
                case "Fund Allocations":
                    break;
                case "Enrollment Summary":
                    //tab.ImageUrl = "Images/4_normal.png";
                    //tab.SelectedImageUrl = "Images/4_active.png";
                    //tab.DisabledImageUrl = "Images/4_disable.png";
                    break;
                default:
                    break;
            }
     
            rtsEnrollment.Tabs.Add(tab);
        }
     
        private void LoadSalaryElections(RadTab tab)
        {
            RadPageView pvDeferralElections = (RadPageView)tab.PageView.FindControl("deferralElections");
            enrollment_theCompany_deferralElections ucDeferralElections = (enrollment_theCompany_deferralElections)pvDeferralElections.FindControl("ucDeferralElections");
            ucDeferralElections.PlanPeriodName = _enrollment.PlanPeriodName;
            ucDeferralElections.NextPlanPeriodName = _enrollment.NextPlanPeriodName;
            ucDeferralElections.LoadDeferralElections(_enrollment);       
        }
     
         private void LoadDistributionElections(RadTab tab)
         {
             RadPageView pvPaymentOptions = (RadPageView)tab.PageView.FindControl("paymentOptions");
             enrollment_theCompany_paymentOptions ucPaymentOptions = (enrollment_theCompany_paymentOptions)pvPaymentOptions.FindControl("ucPaymentOptions");        
              
             ucPaymentOptions.LoadPaymentOptions(_enrollment);
         }   
        #endregion
    }
  2. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 11 Jun 2014 in reply to MBEN Link to this post

    I used the MultiPage PreRender event to call my LoadStep() function and it seems to be doing the trick.
    Let me know if that isn't the best place to make that call.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 16 Jun 2014 Link to this post

    Hi,

    It looks like a proper solution for this specific scenario.

    Regards,
    Plamen
    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.

     
  5. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 16 Jun 2014 in reply to Plamen Link to this post

    I moved my buttons to a master page because I use the same buttons for different pages where I call the wizard for different clients.
    I need to show or hide the buttons based on what tab I am on.
    Everything works fine except when I navigate using tab click. It does not hide my buttons (I suspect it is not updating the buttons).
    I added an ajaxsetting for those buttons on my content page to update the buttons on my tab click. That works but my validation on the page stops working. if I remove the AJAX Settings my validations start working but the buttons don't hide/show appropriately.

    Below is my new declaration. Please let me know what I can do.

    Master Page:
     
    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="enrollmentWizard.master.cs"
        Inherits="enrollment_enrollmentWizard" MasterPageFile="~/site.master" %>
    <%@ MasterType VirtualPath="~/site.master" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
        </asp:ContentPlaceHolder>
        <table id="enrollmentButton">
            <tr>
                <td>               
                        <telerik:RadButton runat="server" ID="PreviousButton" Text="<< Previous" AutoPostBack="true"
                            CausesValidation="false">
                        </telerik:RadButton>
                        <telerik:RadButton runat="server" ID="ContinueButton" Text="Next >>" CausesValidation="true"
                            AutoPostBack="true">
                        </telerik:RadButton>
                        <telerik:RadButton runat="server" ID="FinishButton" Text="Finish" CausesValidation="true"
                            AutoPostBack="true">
                        </telerik:RadButton>               
                </td>
            </tr>
        </table>
    </asp:Content>
     
    master code behind:
     
    public partial class enrollment_enrollmentWizard  : MasterPage
    {
       public void InitializeStep(Enrollment _enrollment, RadTabStrip ts)
        {
            InitializeButtons(ts);
        }
     
        public void InitializeButtons(RadTabStrip ts)
        {
            string tabName = ts.SelectedTab.Text;
            RadTab tab = ts.FindTabByText(tabName);
     
            switch (ts.SelectedTab.Text)
            {
                case "Deferral Elections":
                    PreviousButton.Visible = false;
                    ContinueButton.Visible = true;
                    FinishButton.Visible = false;
                    break;
     
                case "Distribution Elections":
                    PreviousButton.Visible = true;
                    ContinueButton.Visible = true;
                    FinishButton.Visible = false;
                    break;
     
                case "Fund Allocations":
                    PreviousButton.Visible = true;
                    ContinueButton.Visible = true;
                    FinishButton.Visible = false;
                    break;
     
                case "Enrollment Summary":
                    PreviousButton.Visible = true;
                    ContinueButton.Visible = false;
                    FinishButton.Visible = true;
                    break;
            }
        }
     
        #region Properties
        public RadButton PreviousButtonFromMaster
        {
            get
            
                return PreviousButton;
            }
        }
        public RadButton ContinueButtonFromMaster
        {
            get
            {
                return ContinueButton;
            }
        }
        public RadButton FinishButtonFromMaster
        {
            get
            {
                return FinishButton;
            }
        }
        #endregion
    }
     
    content page:
     
    <%@ Page Language="C#" MasterPageFile="~/enrollment/enrollmentWizard.master" AutoEventWireup="true"
        CodeFile="EDCP.aspx.cs" Inherits="enrollment_theCompany_EDCP" Title="M Benefit Solutions: The Comapny Enrollment" %>
     
    <%@ MasterType VirtualPath="~/enrollment/enrollmentWizard.master" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <%@ Register TagPrefix="iSys" TagName="summary" Src="~/enrollment/ucEnrollmentSummary.ascx" %>
    <%@ Register TagPrefix="iSys" TagName="fundBucket" Src="~/fund/ucFundbucket.ascx" %>
    <%@ Register TagPrefix="iSys" TagName="deferralElections" Src="~/enrollment/thecompany/deferralElections.ascx" %>
    <%@ Register TagPrefix="iSys" TagName="paymentOptions" Src="~/enrollment/thecompany/paymentOptions.ascx" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
        <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rmpEnrollment">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rtsEnrollment" />
                        <telerik:AjaxUpdatedControl ControlID="rmpEnrollment" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rtsEnrollment">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rtsEnrollment" />
                        <telerik:AjaxUpdatedControl ControlID="rmpEnrollment" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td>
                    <telerik:RadTabStrip ID="rtsEnrollment" runat="server" MultiPageID="rmpEnrollment"
                        OnTabClick="rtsEnrollment_TabClick" SelectedIndex="0" CausesValidation="true"
                        Align="Justify" AutoPostBack="true">
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage ID="rmpEnrollment" runat="server" SelectedIndex="0" OnPageViewCreated="rmpEnrollment_PageViewCreated"
                        OnPreRender="rmpEnrollment_PreRender" RenderSelectedPageOnly="true" CssClass="multiPage">
                    </telerik:RadMultiPage>
                </td>
            </tr>
        </table>
    </asp:Content>
     
    content page code behind:
     
    public partial class enrollment_EDCP : EnrollmentBasePage
    {
        protected override void LoadStep()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
            RadTab tab = rtsEnrollment.FindTabByText(tabName);
     
            switch (rtsEnrollment.SelectedTab.Text)
            {
                case "Deferral Elections":
                    LoadSalaryElections(tab);
                    break;
     
                case "Distribution Elections":
                    LoadDistributionElections(tab);
                    break;
     
                case "Fund Allocations":
                    RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                    ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                    break;
     
                case "Enrollment Summary":
                    // commit data
                    break;
     
                default:
                    break;
            }
     
            this.Master.InitializeStep(_enrollment, rtsEnrollment);
        }
     
        protected override void UpdateStep(int nextStepIndex)
        {
           Save();
        }
     
        protected void Page_Init(object sender, EventArgs e)
        {
            Page page = this.Page;
            enrollment_enrollmentWizard mp = (enrollment_enrollmentWizard)page.Master;
            mp.PreviousButtonFromMaster.Click += new EventHandler(PreviousButton_Click);
            mp.ContinueButtonFromMaster.Click += new EventHandler(ContinueButton_Click);
            mp.FinishButtonFromMaster.Click += new EventHandler(FinishButton_Click);
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AddTab("Deferral Elections", true);
     
                RadPageView pageView = new RadPageView();
                pageView.ID = "DeferralElections";
                rmpEnrollment.PageViews.Add(pageView);
     
                AddTab("Distribution Elections", false);
                AddTab("Fund Allocations", false);
                AddTab("Enrollment Summary", false);
     
                LoadStep();
            }
     
            RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(Page);
            enrollment_enrollmentWizard mp = (enrollment_enrollmentWizard)Page.Master;
            RadButton PreviousButton = mp.PreviousButtonFromMaster;
            RadButton ContinueButton = mp.ContinueButtonFromMaster;
            RadButton FinishButton = mp.FinishButtonFromMaster;
            AjaxManager.AjaxSettings.AddAjaxSetting(rtsEnrollment, PreviousButton);
            AjaxManager.AjaxSettings.AddAjaxSetting(rtsEnrollment, ContinueButton);
            AjaxManager.AjaxSettings.AddAjaxSetting(rtsEnrollment, FinishButton);
        }
     
        #region UI Events
     
        protected void rmpEnrollment_PreRender(object sender, EventArgs e)
        {
            LoadStep();
        }
     
        protected void rmpEnrollment_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            Control pageViewContents = new Control();
            switch (e.PageView.ID)
            {
                case "DeferralElections":
                    pageViewContents = LoadControl("~/enrollment/thecompany/deferralElections.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID ;
                    break;
                case "PaymentOptions":
                    pageViewContents = LoadControl("~/enrollment/thecompany/paymentOptions.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
                case "FundAllocations":
                    pageViewContents = LoadControl("~/fund/ucFundbucket.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
                case "EnrollmentSummary":
                    pageViewContents = LoadControl("~/enrollment/ucEnrollmentSummary.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
            }
     
            e.PageView.Controls.Add(pageViewContents);
        }
     
        protected void rtsEnrollment_TabClick(object sender, RadTabStripEventArgs e)
        {
            Page.Validate(rtsEnrollment.ValidationGroup);
            if (Page.IsValid)
                rtsEnrollment.ValidationGroup = e.Tab.Value;
     
            LoadStep();       
        }
       protected void PreviousButton_Click(object sender, EventArgs e)
        {      
        }
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
        }
        protected void FinishButton_Click(object sender, EventArgs e)
        {
        }   
        #endregion
     
        #region Private Events
        private void GoToNextTab()
        {       
        }
     
        private void GoToNextPageView()
        {
        }
     
        private void GoToPreviousTab()
        {
        }
     
        private void GoToPreviousPageView()
        {
        }
        #endregion
    }
  6. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 16 Jun 2014 in reply to MBEN Link to this post

    I tried to put a RadAJAXPanel in my master page around the buttons and my contentplaceholder and took the RadAjaxSettings out. That seems to be working fine.

    However, using the above code, if I navigate between the tabs my data is not getting saved.
    I call the below function on my next and previous button click events and that works fine. If I try to call the same event on tabClick, the selectedtab has already changed. What would be the most appropriate place to call the update function on tabclick?

    protected override void UpdateStep(int nextStepIndex)
        {
            if (base.IsCurrentEmployee)
            {
                string tabName = rtsEnrollment.SelectedTab.Text;
                RadTab tab = rtsEnrollment.FindTabByText(tabName);
                switch (tabName)
                {
                    case "Deferral Elections":
                        RadPageView pvDeferralElections = (RadPageView)tab.PageView.FindControl("deferralElections");
                        enrollment_theCompany_deferralElections ucDeferralElections = (enrollment_theCompany_deferralElections)pvDeferralElections.FindControl("ucDeferralElections");
                        ucDeferralElections.SaveForEnrollment(_enrollment);
                        break;
     
                    case "Distribution Elections":
                        RadPageView pvPaymentOptions = (RadPageView)tab.PageView.FindControl("paymentOptions");
                        enrollment_theCompany_paymentOptions ucPaymentOptions = (enrollment_theCompany_paymentOptions)pvPaymentOptions.FindControl("ucPaymentOptions");
                        ucPaymentOptions.PlanPeriodName = _enrollment.PlanPeriodName;
                        ucPaymentOptions.SaveForEnrollment(_enrollment);
                        break;
     
                    case "Fund Allocations":
                        RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                        ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                        ucFundAllocations.SaveAllocationForEnrollment(_enrollment);
                        break;
     
                    case "Enrollment Summary":
                        break;
                }
                SaveActivity(rtsEnrollment, nextStepIndex);
            }
        }
  7. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 20 Jun 2014 Link to this post

    Hello,

    The described behavior is quite unusual with the data not being saved is quite unusual. You can try to set the data in PageInit method in case it makes difference in your case.

    Regards,
    Plamen
    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.

     
  8. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 23 Jun 2014 in reply to Plamen Link to this post

    The code does not work in Page_Init.
    string tabName = rtsEnrollment.SelectedTab gives me null.
    Also I want to save the changes only when the tab is changed. When the user moves to tab2 from tab1 I want to save the data on tab1.

    As soon as I click on the tab2 the active tab becomes tab2 and my update code saves the data for tab2.

    I think the issue is that my pageviewcreated event is fired before my tabclick event but I am not sure how to get around that.
    I have posted my code below for your reference again:
    aspx:
     
    <%@ Page Language="C#" MasterPageFile="~/enrollment/enrollmentWizard.master" AutoEventWireup="true"
        CodeFile="EDCP.aspx.cs" Inherits="enrollment_theCompany_EDCP" Title="Comapny Enrollment" %>
     
    <%@ MasterType VirtualPath="~/enrollment/enrollmentWizard.master" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <%@ Register TagPrefix="iSys" TagName="summary" Src="~/enrollment/ucEnrollmentSummary.ascx" %>
    <%@ Register TagPrefix="iSys" TagName="fundBucket" Src="~/fund/ucFundbucket.ascx" %>
    <%@ Register TagPrefix="iSys" TagName="deferralElections" Src="~/enrollment/thecompany/deferralElections.ascx" %>
    <%@ Register TagPrefix="iSys" TagName="paymentOptions" Src="~/enrollment/thecompany/paymentOptions.ascx" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">  
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td>
                    <telerik:RadTabStrip ID="rtsEnrollment" runat="server" MultiPageID="rmpEnrollment"
                        OnTabClick="rtsEnrollment_TabClick" SelectedIndex="0" CausesValidation="true"
                        Align="Justify" AutoPostBack="true">
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage ID="rmpEnrollment" runat="server" SelectedIndex="0" OnPageViewCreated="rmpEnrollment_PageViewCreated"
                        OnPreRender="rmpEnrollment_PreRender" RenderSelectedPageOnly="true" CssClass="multiPage">
                    </telerik:RadMultiPage>
                </td>
            </tr>
        </table>
    </asp:Content>
     
    aspx.cs
     
    public partial class enrollment_theCompany_EDCP : EnrollmentBasePage
    {
        protected override void LoadStep()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
            RadTab tab = rtsEnrollment.FindTabByText(tabName);
     
            switch (rtsEnrollment.SelectedTab.Text)
            {
                case "Deferral Elections":
                    LoadSalaryElections(tab);
                    break;
     
                case "Distribution Elections":
                    LoadDistributionElections(tab);
                    break;
     
                case "Fund Allocations":
                    LoadPlan();
                    break;
     
                case "Enrollment Summary":
                    // commit data
                    break;
            }
     
            this.Master.InitializeStep(_enrollment, rtsEnrollment);
        }
     
        protected override void UpdateStep(int nextStepIndex)
        {
            if (base.IsCurrentEmployee)
            {
                string tabName = rtsEnrollment.SelectedTab.Text;
                RadTab tab = rtsEnrollment.FindTabByText(tabName);
                switch (tabName)
                {
                    case "Deferral Elections":
                        RadPageView pvDeferralElections = (RadPageView)tab.PageView.FindControl("deferralElections");
                        enrollment_theCompany_deferralElections ucDeferralElections = (enrollment_theCompany_deferralElections)pvDeferralElections.FindControl("ucDeferralElections");
                        ucDeferralElections.Save(_enrollment);
                        break;
     
                    case "Distribution Elections":
                        RadPageView pvPaymentOptions = (RadPageView)tab.PageView.FindControl("paymentOptions");
                        enrollment_theCompany_paymentOptions ucPaymentOptions = (enrollment_theCompany_paymentOptions)pvPaymentOptions.FindControl("ucPaymentOptions");
                        ucPaymentOptions.PlanPeriodName = _enrollment.PlanPeriodName;
                        ucPaymentOptions.Save(_enrollment);
                        break;
     
                    case "Fund Allocations":
                        RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                        ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                        ucFundAllocations.Save(_enrollment);
                        break;
     
                    case "Enrollment Summary":
                        break;
                }
                SaveActivity(rtsEnrollment, nextStepIndex);
            }
        }
     
        protected void Page_Init(object sender, EventArgs e)
        {
            Page page = this.Page;
            enrollment_enrollmentWizard mp = (enrollment_enrollmentWizard)page.Master;
            mp.PreviousButtonFromMaster.Click += new EventHandler(PreviousButton_Click);
            mp.ContinueButtonFromMaster.Click += new EventHandler(ContinueButton_Click);
            mp.FinishButtonFromMaster.Click += new EventHandler(FinishButton_Click);
            mp.UpdateBeneficiaryDesignationDButtonFromMaster.Click += new EventHandler(UpdateBeneficiaryDesignationButton_Click);       
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AddTab("Deferral Elections", true);
     
                RadPageView pageView = new RadPageView();
                pageView.ID = "DeferralElections";
                rmpEnrollment.PageViews.Add(pageView);
     
                AddTab("Distribution Elections", false);
                AddTab("Fund Allocations", false);
                AddTab("Enrollment Summary", false);
            }       
        }
     
        #region UI Events
     
        protected void rmpEnrollment_PreRender(object sender, EventArgs e)
        {
            LoadStep();
        }
     
        protected void rmpEnrollment_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            Control pageViewContents = new Control();
            switch (e.PageView.ID)
            {
                case "DeferralElections":
                    pageViewContents = LoadControl("~/enrollment/thecompany/deferralElections.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID ;
                    break;
                case "PaymentOptions":
                    pageViewContents = LoadControl("~/enrollment/thecompany/paymentOptions.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
                case "FundAllocations":
                    pageViewContents = LoadControl("~/fund/ucFundbucket.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
                case "EnrollmentSummary":
                    pageViewContents = LoadControl("~/enrollment/ucEnrollmentSummary.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    break;
            }
     
            e.PageView.Controls.Add(pageViewContents);
        }
     
        protected void rtsEnrollment_TabClick(object sender, RadTabStripEventArgs e)
        {
            Page.Validate(rtsEnrollment.ValidationGroup);
            if (Page.IsValid)
                rtsEnrollment.ValidationGroup = e.Tab.Value;
     
            UpdateStep();     
        }
     
        protected void UpdateBeneficiaryDesignationButton_Click(object sender, EventArgs e)
        {
            LoadBeneficiaryDesignations();
            Response.Redirect("~/elections/BeneficiaryChange/beneficiaryChange.aspx", true);
        }
     
        protected void PreviousButton_Click(object sender, EventArgs e)
        {
            GoToPreviousTab();
            GoToPreviousPageView();
        }
     
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            UpdateStep();       
            GoToNextTab();
            GoToNextPageView();
        }
     
        protected void FinishButton_Click(object sender, EventArgs e)
        {
            UpdateStep();
            Response.Redirect(Utility.StartPage());
        }
         
        #endregion
     
        #region Private Events
     
        private void LoadBeneficiaryDesignations()
        {
            //code
        }
     
        private void GoToNextTab()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    RadTab paymentOptionsTab = rtsEnrollment.FindTabByText("Distribution Elections");
                    rtsEnrollment.ValidationGroup = "PaymentOptionsTabValidationGroup";
                    paymentOptionsTab.Enabled = true;
                    paymentOptionsTab.Selected = true;
                    break;
     
                case "Distribution Elections":
                    RadTab fundAllocationsTab = rtsEnrollment.FindTabByText("Fund Allocations");
                    fundAllocationsTab.Enabled = true;
                    fundAllocationsTab.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadTab enrollmentSummaryTab = rtsEnrollment.FindTabByText("Enrollment Summary");
                    enrollmentSummaryTab.Enabled = true;
                    enrollmentSummaryTab.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    break;
            }       
        }
     
        private void GoToNextPageView()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    break;
     
                case "Distribution Elections":
                    RadPageView paymentOptionsTabPageView = rmpEnrollment.FindPageViewByID("PaymentOptions");
                    if (paymentOptionsTabPageView == null)
                    {
                        paymentOptionsTabPageView = new RadPageView();
                        paymentOptionsTabPageView.ID = "PaymentOptions";
                        rmpEnrollment.PageViews.Add(paymentOptionsTabPageView);
                    }
                    paymentOptionsTabPageView.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadPageView fundAllocationsTabPageView = rmpEnrollment.FindPageViewByID("FundAllocations");
                    if (fundAllocationsTabPageView == null)
                    {
                        fundAllocationsTabPageView = new RadPageView();
                        fundAllocationsTabPageView.ID = "FundAllocations";
                        rmpEnrollment.PageViews.Add(fundAllocationsTabPageView);
                    }
                    fundAllocationsTabPageView.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    RadPageView enrollmentSummaryTabPageView = rmpEnrollment.FindPageViewByID("EnrollmentSummary");
                    if (enrollmentSummaryTabPageView == null)
                    {
                        enrollmentSummaryTabPageView = new RadPageView();
                        enrollmentSummaryTabPageView.ID = "EnrollmentSummary";
                        rmpEnrollment.PageViews.Add(enrollmentSummaryTabPageView);
                    }
                    enrollmentSummaryTabPageView.Selected = true;
                    break;
            }
        }
     
        private void GoToPreviousTab()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    break;
     
                case "Distribution Elections":
                    RadTab deferralElectionsTab = rtsEnrollment.FindTabByText("Deferral Elections");
                    rtsEnrollment.ValidationGroup = "DeferralElectionsTabValidationGroup";
                    deferralElectionsTab.Enabled = true;
                    deferralElectionsTab.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadTab paymentOptionsTab = rtsEnrollment.FindTabByText("Distribution Elections");
                    rtsEnrollment.ValidationGroup = "PaymentOptionsTabValidationGroup";
                    paymentOptionsTab.Enabled = true;
                    paymentOptionsTab.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    RadTab FundAllocationsTab = rtsEnrollment.FindTabByText("Fund Allocations");
                    FundAllocationsTab.Enabled = true;
                    FundAllocationsTab.Selected = true;
                    break;
            }
        }
     
        private void GoToPreviousPageView()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    RadPageView deferralElectionsTabPageView = rmpEnrollment.FindPageViewByID("DeferralElections");
                    if (deferralElectionsTabPageView == null)
                    {
                        deferralElectionsTabPageView = new RadPageView();
                        deferralElectionsTabPageView.ID = "DeferralElections";
                        rmpEnrollment.PageViews.Add(deferralElectionsTabPageView);
                    }
                    deferralElectionsTabPageView.Selected = true;
                    break;
     
                case "Distribution Elections":
                    RadPageView paymentOptionsTabPageView = rmpEnrollment.FindPageViewByID("PaymentOptions");
                    if (paymentOptionsTabPageView == null)
                    {
                        paymentOptionsTabPageView = new RadPageView();
                        paymentOptionsTabPageView.ID = "PaymentOptions";
                        rmpEnrollment.PageViews.Add(paymentOptionsTabPageView);
                    }
                    paymentOptionsTabPageView.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadPageView fundAllocationsTabPageView = rmpEnrollment.FindPageViewByID("FundAllocations");
                    if (fundAllocationsTabPageView == null)
                    {
                        fundAllocationsTabPageView = new RadPageView();
                        fundAllocationsTabPageView.ID = "FundAllocations";
                        rmpEnrollment.PageViews.Add(fundAllocationsTabPageView);
                    }
                    fundAllocationsTabPageView.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    break;
            }
        }
         
        private void AddTab(string tabName, bool enabled)
        {
            RadTab tab = new RadTab(tabName);
            tab.Enabled = enabled;
            rtsEnrollment.Tabs.Add(tab);
        }
     
        private void LoadSalaryElections(RadTab tab)
        {
            RadPageView pvDeferralElections = (RadPageView)tab.PageView.FindControl("deferralElections");
            enrollment_theCompany_deferralElections ucDeferralElections = (enrollment_theCompany_deferralElections)pvDeferralElections.FindControl("ucDeferralElections");
            ucDeferralElections.LoadDeferralElections(_enrollment);       
        }
     
         private void LoadDistributionElections(RadTab tab)
         {
             RadPageView pvPaymentOptions = (RadPageView)tab.PageView.FindControl("paymentOptions");
             enrollment_theCompany_paymentOptions ucPaymentOptions = (enrollment_theCompany_paymentOptions)pvPaymentOptions.FindControl("ucPaymentOptions");
             ucPaymentOptions.LoadPaymentOptions(_enrollment);
         }   
        #endregion
    }

    Please help.
  9. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 25 Jun 2014 in reply to MBEN Link to this post

    Any update on this?
  10. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 26 Jun 2014 Link to this post

    Hi,

    Thank you for sending all the code.

    I have inspected the code once again. In such scenarios when you need to update the controls in the PageView you have to use its PageViewCreated event and update it there- so in your case you have to move your LoadStep logic in the PageViewCreated event.

    Hope this will help you solve the issue.

    Regards,
    Plamen
    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.

     
  11. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 26 Jun 2014 in reply to Plamen Link to this post

    I added my LoadStep logic to PageViewCreated and it seems to be working now.
  12. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 07 Jul 2014 in reply to MBEN Link to this post

    Hi,

    I am having issues with one of the steps in my wizard.
    I have a grid on one of the steps - FundAllocation that I render in edit mode. I want to use the Next Step or tab click event to update the grid.
    However my edited values are lost when i do next.

    I suspect this is because my pageviewcreated event is fired before my update event and the grid is recreated at that point.
    Is there a workaround that?

        protected override void UpdateStep(int nextStepIndex)
        {       
                string tabName = rtsEnrollment.SelectedTab.Text;
                RadTab tab = rtsEnrollment.FindTabByText(tabName);
                switch (tabName)
                {
                    case "Deferral Elections":
                        RadPageView pvDeferralElections = (RadPageView)tab.PageView.FindControl("deferralElections");
                        enrollment_theCompany_deferralElections ucDeferralElections = (enrollment_theCompany_deferralElections)pvDeferralElections.FindControl("ucDeferralElections");
                        ucDeferralElections.SaveForEnrollment(_enrollment);
                        break;
                    case "Distribution Elections":
                        RadPageView pvPaymentOptions = (RadPageView)tab.PageView.FindControl("paymentOptions");
                        enrollment_theCompany_paymentOptions ucPaymentOptions = (enrollment_theCompany_paymentOptions)pvPaymentOptions.FindControl("ucPaymentOptions");
                        ucPaymentOptions.PlanPeriodName = _enrollment.PlanPeriodName;
                        ucPaymentOptions.SaveForEnrollment(_enrollment);
                        break;
                    case "Fund Allocations":
                        RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                        ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                        ucFundAllocations.SaveAllocationForEnrollment(_enrollment);
                        break;
                    case "Enrollment Summary":
                        break;
                }
        }
     
       protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AddTab("Deferral Elections", true);
     
                RadPageView pageView = new RadPageView();
                pageView.ID = "DeferralElections";
                rmpEnrollment.PageViews.Add(pageView);
     
                AddTab("Distribution Elections", false);
                AddTab("Fund Allocations", false);
                AddTab("Enrollment Summary", false);
            }       
        }
     
        #region UI Events
     
       protected void rmpEnrollment_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            Control pageViewContents = new Control();
            RadTab tab;
            switch (e.PageView.ID)
            {
                case "DeferralElections":
                    pageViewContents = LoadControl("~/enrollment/thecompany/deferralElections.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    e.PageView.Controls.Add(pageViewContents);
                    tab = rtsEnrollment.FindTabByText("Deferral Elections");
                    LoadSalaryElections(tab);
                    break;
                case "PaymentOptions":
                    pageViewContents = LoadControl("~/enrollment/thecompany/paymentOptions.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    e.PageView.Controls.Add(pageViewContents);
                    tab = rtsEnrollment.FindTabByText("Distribution Elections");
                    LoadDistributionElections(tab);
                    break;
                case "FundAllocations":
                    pageViewContents = LoadControl("~/fund/ucFundbucket.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    tab = rtsEnrollment.FindTabByText("Fund Allocations");
                    RadPageView pvFundAllocations = (RadPageView)tab.PageView.FindControl("fundAllocations");
                    e.PageView.Controls.Add(pageViewContents);
                    ucFundBucket ucFundAllocations = (ucFundBucket)pvFundAllocations.FindControl("ucFundAllocations");
                    ucFundAllocations.ShowPostTransactionButton = false;
                    ucFundAllocations.LoadPlan();
                    break;
                case "EnrollmentSummary":
                    pageViewContents = LoadControl("~/enrollment/ucEnrollmentSummary.ascx");
                    pageViewContents.ID = "uc" + e.PageView.ID;
                    tab = rtsEnrollment.FindTabByText("Enrollment Summary");// commit data
                    RadPageView pvEnrollmentSummary = (RadPageView)tab.PageView.FindControl("enrollmentSummary");
                    e.PageView.Controls.Add(pageViewContents);
                    enrollment_ucEnrollmentSummary ucEnrollmentSummary = (enrollment_ucEnrollmentSummary)pvEnrollmentSummary.FindControl("ucEnrollmentSummary");
                    _enrollment.CommitEnrollmentData(DeferralSources());
                    ucEnrollmentSummary.ConfirmationID = _enrollment.ConfirmationID;
                    break;
            }
        }
     
        protected void rtsEnrollment_TabClick(object sender, RadTabStripEventArgs e)
        {
            Page.Validate(rtsEnrollment.ValidationGroup);
            if (Page.IsValid)
                rtsEnrollment.ValidationGroup = e.Tab.Value;
     
            UpdateStep();     
        }
     
       protected void PreviousButton_Click(object sender, EventArgs e)
        {
            GoToPreviousTab();
            GoToPreviousPageView();
        }
     
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            UpdateStep();       
            GoToNextTab();
            GoToNextPageView();
        }
     
        protected void FinishButton_Click(object sender, EventArgs e)
        {
            UpdateStep();
        }
         
        #endregion
     
        #region Private Events
     
        private void GoToNextTab()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    RadTab paymentOptionsTab = rtsEnrollment.FindTabByText("Distribution Elections");
                    rtsEnrollment.ValidationGroup = "PaymentOptionsTabValidationGroup";
                    paymentOptionsTab.Enabled = true;
                    paymentOptionsTab.Selected = true;
                    break;
     
                case "Distribution Elections":
                    RadTab fundAllocationsTab = rtsEnrollment.FindTabByText("Fund Allocations");
                    fundAllocationsTab.Enabled = true;
                    fundAllocationsTab.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadTab enrollmentSummaryTab = rtsEnrollment.FindTabByText("Enrollment Summary");
                    enrollmentSummaryTab.Enabled = true;
                    enrollmentSummaryTab.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    break;
            }       
        }
     
        private void GoToNextPageView()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    break;
     
                case "Distribution Elections":
                    RadPageView paymentOptionsTabPageView = rmpEnrollment.FindPageViewByID("PaymentOptions");
                    if (paymentOptionsTabPageView == null)
                    {
                        paymentOptionsTabPageView = new RadPageView();
                        paymentOptionsTabPageView.ID = "PaymentOptions";
                        rmpEnrollment.PageViews.Add(paymentOptionsTabPageView);
                    }
                    paymentOptionsTabPageView.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadPageView fundAllocationsTabPageView = rmpEnrollment.FindPageViewByID("FundAllocations");
                    fundAllocationsTabPageView.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    RadPageView enrollmentSummaryTabPageView = rmpEnrollment.FindPageViewByID("EnrollmentSummary");
                    if (enrollmentSummaryTabPageView == null)
                    {
                        enrollmentSummaryTabPageView = new RadPageView();
                        enrollmentSummaryTabPageView.ID = "EnrollmentSummary";
                        rmpEnrollment.PageViews.Add(enrollmentSummaryTabPageView);
                    }
                    enrollmentSummaryTabPageView.Selected = true;
                    break;
            }
        }
     
        private void GoToPreviousTab()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    break;
     
                case "Distribution Elections":
                    RadTab deferralElectionsTab = rtsEnrollment.FindTabByText("Deferral Elections");
                    rtsEnrollment.ValidationGroup = "DeferralElectionsTabValidationGroup";
                    deferralElectionsTab.Enabled = true;
                    deferralElectionsTab.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadTab paymentOptionsTab = rtsEnrollment.FindTabByText("Distribution Elections");
                    rtsEnrollment.ValidationGroup = "PaymentOptionsTabValidationGroup";
                    paymentOptionsTab.Enabled = true;
                    paymentOptionsTab.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    RadTab FundAllocationsTab = rtsEnrollment.FindTabByText("Fund Allocations");
                    FundAllocationsTab.Enabled = true;
                    FundAllocationsTab.Selected = true;
                    break;
            }
        }
     
        private void GoToPreviousPageView()
        {
            string tabName = rtsEnrollment.SelectedTab.Text;
     
            switch (tabName)
            {
                case "Deferral Elections":
                    RadPageView deferralElectionsTabPageView = rmpEnrollment.FindPageViewByID("DeferralElections");
                    if (deferralElectionsTabPageView == null)
                    {
                        deferralElectionsTabPageView = new RadPageView();
                        deferralElectionsTabPageView.ID = "DeferralElections";
                        rmpEnrollment.PageViews.Add(deferralElectionsTabPageView);
                    }
                    deferralElectionsTabPageView.Selected = true;
                    break;
     
                case "Distribution Elections":
                    RadPageView paymentOptionsTabPageView = rmpEnrollment.FindPageViewByID("PaymentOptions");
                    if (paymentOptionsTabPageView == null)
                    {
                        paymentOptionsTabPageView = new RadPageView();
                        paymentOptionsTabPageView.ID = "PaymentOptions";
                        rmpEnrollment.PageViews.Add(paymentOptionsTabPageView);
                    }
                    paymentOptionsTabPageView.Selected = true;
                    break;
     
                case "Fund Allocations":
                    RadPageView fundAllocationsTabPageView = rmpEnrollment.FindPageViewByID("FundAllocations");
                    if (fundAllocationsTabPageView == null)
                    {
                        fundAllocationsTabPageView = new RadPageView();
                        fundAllocationsTabPageView.ID = "FundAllocations";
                        rmpEnrollment.PageViews.Add(fundAllocationsTabPageView);
                    }
                    fundAllocationsTabPageView.Selected = true;
                    break;
     
                case "Enrollment Summary":
                    break;
            }
        }
        #endregion
    }

    Save routine for saving the grid values:
    public void SaveAllocationForEnrollment(Enrollment ec)
            {
                // save the new allocations to the enrollment data
                foreach (GridDataItem item in rgFunds.Items)
                {
                    string newPercent = "";
                    double _rebalancePercent = 0.0;
     
                    // get the fund name and the new percent
                    GridItem gridEditItem = rgFunds.MasterTableView.GetItems(GridItemType.Item).SingleOrDefault(gridItem => gridItem.ItemIndex == item.ItemIndex);
                    if (gridEditItem != null)
                    {
                        Label lblNewPercent = gridEditItem.FindControl("_futurePercent") as Label;
                        newPercent = lblNewPercent.Text.Replace("%", "");
                        _rebalancePercent = Convert.ToDouble(newPercent);
                    }
     
                    HtmlInputHidden _fundID = (HtmlInputHidden)item.FindControl("_fundID");
                    ec.UpdateFundAllocation(Int32.Parse(_fundID.Value), _rebalancePercent.ToString());
                }
            }
     
    : html for grid declaration on the user control:
    <telerik:RadGrid ID="rgFunds" runat="server" AllowSorting="False" EnableViewState="true" AllowPaging="false"
                             GridLines="Both" AllowMultiRowEdit="true" OnPreRender="rgFunds_PreRender" OnItemDataBound="rgFunds_ItemDataBound"
                            OnItemCreated="rgFunds_ItemCreated" OnItemCommand="rgFunds_ItemCommand" OnNeedDataSource="rgFunds_NeedDataSource">
                            <MasterTableView TableLayout="Fixed" HierarchyDefaultExpanded="true" CommandItemDisplay="Bottom"
                                EditMode="InPlace" EnableNoRecordsTemplate="true">
                                <CommandItemTemplate>
                                    <table width="100%">
                                        <tr>
                                            <td colspan="4" align="left">
                                                <asp:CheckBox ID="chkAutoRebalance" runat="server" Visible="false" CssClass="checkbox"
                                                    OnCheckedChanged="chkAutoRebalance_CheckedChanged" />
                                            </td>
                                            <td align="right">
                                                <asp:Button ID="btnPostTransaction" runat="server" Text="Post Transaction" CssClass="button"
                                                    CommandName="PostTransaction" />
                                            </td>
                                        </tr>
                                    </table>
                                </CommandItemTemplate>
                                <Columns>
                                    <telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
                                        FooterStyle-HorizontalAlign="Left" UniqueName="InvestmentOptions" ReadOnly="true"
                                        HeaderText="Investment Options">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="_pdfLink" runat="server" ImageUrl="~/App_Themes/Images/pdf_icon.gif"
                                                Visible="false" />
                                            <asp:Label ID="_color" runat="server">    </asp:Label>
                                            <asp:Label ID="_fundName" runat="server" Text='<%# Eval("fundName")%>'></asp:Label>
                                            <asp:CheckBox ID="_excludeFund" runat="server" Checked='<%# Eval("allowRebalanceExclude")%>'
                                                Text="Exclude?" Visible='<%# Eval("allowRebalanceExclude")%>' />
                                            <input type="hidden" id="_fundID" runat="server" />
                                            <input type="hidden" id="_autoRebalanceFlag" runat="server" />
                                            <input type="hidden" id="_allowRebalance" runat="server" />
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <strong>Total must equal 100%</strong></FooterTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Right" HeaderText="Current %"
                                        HeaderStyle-Width="20%" ReadOnly="true" DataField="currentPercent" UniqueName="currentPercent">
                                        <ItemTemplate>
                                            <asp:Label ID="_currentPercent" runat="server" Text='<%# Eval("currentPercent", "{0:N2}%")%>'>
                                            </asp:Label></ItemTemplate>
                                        <%--<FooterTemplate>
                                            <asp:Label ID="fundTotalOld" runat="server" />%
                                        </FooterTemplate>--%>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Right" UniqueName="futurePercent"
                                        HeaderStyle-Width="20%" HeaderText="New %">
                                        <ItemTemplate>
                                            <asp:Label ID="_futurePercent" runat="server" Text='<%# Eval("futurePercent", "{0:N2}%")%>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="txtNewPercent" runat="server" CssClass="percent" groupName="allocations"
                                                Width="40px" onchange="SumGroup(this, false)" Text='<%# Eval("futurePercent")%>' />
                                            %
                                            <asp:RangeValidator ID="newPercentageRange" runat="server" ControlToValidate="txtNewPercent"
                                                Type="Integer" CssClass="errormessagesmall" Display="None" />
                                            <asp:CustomValidator ID="newPercentageIncrement" runat="server" ControlToValidate="txtNewPercent"
                                                ClientValidationFunction="Mod_ClientValidate" CssClass="errormessagesmall" Display="None" />
                                            <cc1:ValidatorCalloutExtender ID="newPercentageRangeCallout" runat="server" TargetControlID="newPercentageRange"
                                                Width="235px" />
                                            <cc1:ValidatorCalloutExtender ID="newPercentageIncrementCallout" runat="server" TargetControlID="newPercentageIncrement"
                                                Width="235px" />
                                        </EditItemTemplate>
                                        <FooterTemplate>
                                            <asp:TextBox ID="fundTotal" runat="server" CssClass="percent" onfocus="blur()" Enabled="false"
                                                Font-Bold="true" ForeColor="Black" Width="40px" />
                                            %
                                            <asp:CompareValidator ID="totalEqual100" runat="server" ControlToValidate="fundTotal"
                                                ValueToCompare="100" Operator="Equal" CssClass="errormessagesmall" Display="None"
                                                ErrorMessage="New allocations must total 100%." />
                                            <asp:RequiredFieldValidator ID="fundTotalRequired" runat="server" ControlToValidate="fundTotal"
                                                Display="None" Visible="false" ErrorMessage="You <em>must</em> enter an allocation." />
                                            <cc1:ValidatorCalloutExtender ID="fundTotalRequiredCallout" runat="server" TargetControlID="fundTotalRequired"
                                                Width="235px" />
                                            <cc1:ValidatorCalloutExtender ID="totalEqual100Callout" runat="server" TargetControlID="totalEqual100"
                                                Width="235px" />
                                        </FooterTemplate>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>
  13. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 10 Jul 2014 Link to this post

    Hello,

    I have tested the code that you shared but unfortunately the scenario is quite custom and I could not replicate the issue at my side. In such case in order to be more helpful and be able to inspect exactly where is causing the odd behavior we recommend submitting a support ticket where you can attach a runnable sample that will let us debug the exact issue.

    Regards,
    Plamen
    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.

     
  14. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 10 Jul 2014 in reply to Plamen Link to this post

    I have submitted a support ticket for this issue.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017