Problem with RadTabStrip / Tabs / MultiPage / RadAjaxGrid/ListView Controls

8 posts, 0 answers
  1. Kevin F
    Kevin F avatar
    46 posts
    Member since:
    Sep 2009

    Posted 14 Oct 2013 Link to this post

    I've spent days on this and want to see if anyone else has seen this problem.

    I have a tabstrip and multipage.  Tabs and related page views are loaded dynamically.  That functionality seems to work flawlessly, until I introduce tabs/pages with RadGrid and RadListView.

    Each RadGrid and the one RadListView have Add/Edit/Delete functionality.  I can run through the tabs/pageViews with RadGrids on them and do everything I need to do without issues.  However, when I click on to the tab/pageview which has the RadListView, then click back to any of the tabs with RadGrid, and try to add/edit/delete, I see a blank pageview (the rmpHiddenView class is applied on the pageview).

    Again, if I stay off the tab with the RadListView, everything works great.  But right after I click the tab with the RadListView and try to do anything with a RadGrid on another tab, I get the blank page.

    I've attached a JPEG of screen shots. FWIW all of this takes place within a RadWindow.

    Has anybody ever run in to anything like this?  I'd rather not get rid of the RadListView of course.

    Thank you in advance!

    Kevin


  2. Kevin F
    Kevin F avatar
    46 posts
    Member since:
    Sep 2009

    Posted 14 Oct 2013 Link to this post

    Here is the .aspx with the tab strip and the multipage definitions.

    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link href="/sdsoia/Style/popUp.css" rel="stylesheet" />
        <script src="/sdsoia/Scripts/radScripts.js" type="text/javascript"></script>
        <script type="text/javascript">
            function btnDeleteFromQueue_OnClientClicked(button, args) {
                if (window.confirm("Are you sure you want to delete this record from your Queue?")) {
                    button.set_autoPostBack(true);
                }
                else {
                    button.set_autoPostBack(false);
                }
            }
     
            function tabStripOptions_ClientSelecting(sender, args) {
                if (args.get_tab().get_pageView()) {
                    args.get_tab().set_postBack(false);
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
            <telerik:RadAjaxLoadingPanel ID="ajaxLoadingPanel" runat="server" Skin="Windows7"></telerik:RadAjaxLoadingPanel>
            <telerik:RadWindow ID="winSendEmail" runat="server" Behavior="Close, Maximize, Move" Behaviors="Close, Maximize, Move" Width="800px" Height="500px"
                DestroyOnClose="True" KeepInScreenBounds="True" Modal="True" ReloadOnShow="true">
            </telerik:RadWindow>
            <telerik:RadWindow ID="winPrintPreview" runat="server" Behavior="Close, Maximize, Move" Behaviors="Close, Maximize, Move"
                DestroyOnClose="True" KeepInScreenBounds="True" Modal="True" ReloadOnShow="true">
            </telerik:RadWindow>
            <div style="width: 900px;">
                <asp:Panel ID="pnlButtons" runat="server" CssClass="offenderActionButtonsPanel">
                    <telerik:RadButton ID="btnContactRegisteringOffice" runat="server" Text="Contact Registering Office" OnClick="btnContactRegisteringOffice_Click"></telerik:RadButton>
                    <telerik:RadButton ID="btnDeleteFromQueue" runat="server" Text="Delete From Queue" OnClientClicked="btnDeleteFromQueue_OnClientClicked" OnClick="btnDeleteFromQueue_Click"></telerik:RadButton>
                    <telerik:RadButton ID="btnPrintPreview" runat="server" Text="Print Preview" OnClick="btnPrintPreview_Click"></telerik:RadButton>
                </asp:Panel>
            </div>
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="ajaxLoadingPanel">
                <telerik:RadTabStrip ID="tabstripOptions" runat="server" Visible="true" CssClass="offenderSectionTabs" Align="Justify" Width="910"
                    MultiPageID="pagesOptions" OnTabClick="tabstripOptions_TabClick" AutoPostBack="false">
                </telerik:RadTabStrip>
                <telerik:RadMultiPage ID="pagesOptions" runat="server" BackColor="White" OnPageViewCreated="pagesOptions_PageViewCreated"
                    RenderSelectedPageOnly="true">
                </telerik:RadMultiPage>
            </telerik:RadAjaxPanel>
        </form>
    </body>
    </html>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 17 Oct 2013 Link to this post

    Hello Kevin,

    Your markup looks correct and the problem probably comes from the code-behind. Could you share with us a runnable page that we can debug further?

    Regards,
    Vasil
    Telerik
    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 the blog feed now.
  5. Kevin F
    Kevin F avatar
    46 posts
    Member since:
    Sep 2009

    Posted 24 Oct 2013 Link to this post

    Here is the code-behind for the page.  I'm to the point now where I may have to re-write because the RadListView page (Employment Tab) is wreaking havoc with the rest of the tabs once it has been loaded.

    Thanks!!!

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using SorDal;
    using System.Web.Security;
     
    namespace SdSoia.Utility
    {
        public partial class MaintainOffender2 : System.Web.UI.Page
        {
            Sor2PendingDbDataContext pdb;
            Sor2DataContext db;
            Sor2TerminatedDbDataContext tdb;
            PendingOffender thisOffender;
     
            protected void Page_Init(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    Session["CurrentPendingOffenderId"] = Request.QueryString["i"];
                    AddTab("Type");
                    AddTab("Name");
                    AddTab("Aliases");
                    AddTab("Comments");
                    AddTab("Address");
                    AddTab("Mailing Address");
                    AddTab("Previous Residence");
                    AddTab("Secondary Residence");
                    AddTab("Employment");
                    AddTab("Professional License");
                    AddTab("School");
                    AddTab("Vehicle");
                    AddTab("Convictions");
                    AddTab("Contact");
                    AddTab("Crime Description");
                    AddTab("Crimes");
                    AddTab("Victim");
                    AddTab("Status");
                    AddTab("Cert / Sign");
                }
            }
     
            public void NextTab(object sender, EventArgs e)
            {
                RadTab typeTab = tabstripOptions.FindTabByText("Type");
                Ctl.Offenders.OffenderType ctlType = typeTab.PageView.FindControl("pageType_userControl") as Ctl.Offenders.OffenderType;
                CheckBox chkRegEmployment = ctlType.FindControl("chkRegEmployment") as CheckBox;
                RadTab tab = tabstripOptions.SelectedTab;
                if (tab != null)
                {
                    if (!chkRegEmployment.Checked)
                    {
                        switch (tab.Text)
                        {
                            case "Type":
                                tab = tabstripOptions.FindTabByText("Name");
                                break;
                            case "Name":
                                tab = tabstripOptions.FindTabByText("Aliases");
                                break;
                            case "Aliases":
                                tab = tabstripOptions.FindTabByText("Comments");
                                break;
                            case "Comments":
                                tab = tabstripOptions.FindTabByText("Address");
                                break;
                            case "Address":
                                tab = tabstripOptions.FindTabByText("Mailing Address");
                                break;
                            case "Mailing Address":
                                tab = tabstripOptions.FindTabByText("Previous Residence");
                                break;
                            case "Previous Residence":
                                tab = tabstripOptions.FindTabByText("Secondary Residence");
                                break;
                            case "Secondary Residence":
                                tab = tabstripOptions.FindTabByText("Employment");
                                break;
                            case "Employment":
                                tab = tabstripOptions.FindTabByText("Professional License");
                                break;
                            case "Professional License":
                                tab = tabstripOptions.FindTabByText("School");
                                break;
                            case "School":
                                tab = tabstripOptions.FindTabByText("Vehicle");
                                break;
                            case "Vehicle":
                                tab = tabstripOptions.FindTabByText("Convictions");
                                break;
                            case "Convictions":
                                tab = tabstripOptions.FindTabByText("Contact");
                                break;
                            case "Contact":
                                if (!Page.User.IsInRole("System Administrator"))
                                    tab = tabstripOptions.FindTabByText("Crimes");
                                else
                                    tab = tabstripOptions.FindTabByText("Crime Description");
                                break;
                            case "Crime Description":
                                tab = tabstripOptions.FindTabByText("Crimes");
                                break;
                            case "Crimes":
                                tab = tabstripOptions.FindTabByText("Victim");
                                break;
                            case "Victim":
                                tab = tabstripOptions.FindTabByText("Status");
                                break;
                            case "Status":
                                tab = tabstripOptions.FindTabByText("Cert / Sign");
                                break;
                            default:
                                tab = tabstripOptions.FindTabByText("Type");
                                break;
                        }
                    }
                    else
                    {
                        switch (tab.Text)
                        {
                            case "Type":
                                tab = tabstripOptions.FindTabByText("Employment");
                                break;
                            case "Employment":
                                tab = tabstripOptions.FindTabByText("School");
                                break;
                            case "School":
                                tab = tabstripOptions.FindTabByText("Cert / Sign");
                                break;
                            default:
                                tab = tabstripOptions.FindTabByText("Type");
                                break;
                        }
                    }
                    if (tab != null)
                    {
                        tab.Enabled = true;
                        //tab.Selected = true;
                        tabstripOptions_TabClick(tabstripOptions, new RadTabStripEventArgs(tab));
                    }
                }
                else
                {
                    tab = tabstripOptions.FindTabByText("Type");
                    tab.Enabled = true;
                    //tab.Selected = true;
                    tabstripOptions_TabClick(tabstripOptions, new RadTabStripEventArgs(tab));
                }
            }
     
            private void AddTab(string tabName)
            {
                RadTab tab = new RadTab();
                tab.Text = tabName;
                if (tabName == "Employment")
                {
                    tab.IsBreak = true;
                }
                if (tabName == "Crime Description" && !Page.User.IsInRole("System Administrator"))
                {
                    // do nothing, LE not allowed to enter crime descriptions
                }
                else
                {
                    tabstripOptions.Tabs.Add(tab);
                }
                if (tabName == "Type") tabstripOptions_TabClick(tabstripOptions, new RadTabStripEventArgs(tab));
            }
     
            private void AddPageView(RadTab tab)
            {
                RadPageView pageView;
                if (tab.PageView == null || String.IsNullOrEmpty(tab.PageViewID))
                {
                    pageView = new RadPageView();
                    pageView.ID = "page" + tab.Text.Replace(" ", "").Replace("/", "");
                }
                else
                {
                    pageView = tab.PageView;
                }
     
                if (pagesOptions.PageViews.IndexOf(pageView) < 0)
                    pagesOptions.PageViews.Add(pageView);
     
                tab.PageViewID = pageView.ID;
                tab.Selected = true;
                pageView.Selected = true;
            }
     
            protected void pagesOptions_PageViewCreated(object sender, Telerik.Web.UI.RadMultiPageEventArgs e)
            {
                string userControlName = string.Empty;
                switch (e.PageView.ID)
                {
                    case "pageType":
                        userControlName = "~/Ctl/Offenders/OffenderType.ascx";
                        Ctl.Offenders.OffenderType userControl = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderType;
                        userControl.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl);
                        userControl.SaveButtonClicked += new EventHandler(NextTab);
                        break;
                    case "pageName":
                        userControlName = "~/Ctl/Offenders/OffenderName.ascx";
                        var userControl2 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderName;
                        userControl2.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl2);
                        userControl2.SaveButtonClicked += new EventHandler(NextTab);
                        userControl2.InitializeValues();
                        break;
                    case "pageAliases":
                        userControlName = "~/Ctl/Offenders/OffenderAliases.ascx";
                        var userControl3 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderAliases;
                        userControl3.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl3);
                        userControl3.SaveButtonClicked += new EventHandler(NextTab);
                        userControl3.InitializeValues();
                        break;
                    case "pageComments":
                        userControlName = "~/Ctl/Offenders/OffenderComments.ascx";
                        var userControl4 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderComments;
                        userControl4.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl4);
                        userControl4.SaveButtonClicked += new EventHandler(NextTab);
                        userControl4.InitializeValues();
                        break;
                    case "pageAddress":
                        userControlName = "~/Ctl/Offenders/OffenderAddress.ascx";
                        var userControl5 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderAddress;
                        userControl5.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl5);
                        userControl5.SaveButtonClicked += new EventHandler(NextTab);
                        userControl5.InitializeValues();
                        break;
                    case "pageMailingAddress":
                        userControlName = "~/Ctl/Offenders/OffenderMailingAddress.ascx";
                        var userControl6 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderMailingAddress;
                        userControl6.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl6);
                        userControl6.SaveButtonClicked += new EventHandler(NextTab);
                        userControl6.InitializeValues();
                        break;
                    case "pagePreviousResidence":
                        userControlName = "~/Ctl/Offenders/OffenderPreviousResidence.ascx";
                        var userControl7 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderPreviousResidence;
                        userControl7.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl7);
                        userControl7.SaveButtonClicked += new EventHandler(NextTab);
                        userControl7.InitializeValues();
                        break;
                    case "pageSecondaryResidence":
                        userControlName = "~/Ctl/Offenders/OffenderSecondaryAddress.ascx";
                        var userControl8 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderSecondaryAddress;
                        userControl8.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl8);
                        userControl8.SaveButtonClicked += new EventHandler(NextTab);
                        userControl8.InitializeValues();
                        break;
                    case "pageEmployment":
                        userControlName = "~/Ctl/Offenders/OffenderEmployment.ascx";
                        var userControl9 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderEmployment;
                        userControl9.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl9);
                        e.PageView.Selected = true;
                        userControl9.SaveButtonClicked += new EventHandler(NextTab);
                        break;
                    case "pageProfessionalLicense":
                        userControlName = "~/Ctl/Offenders/OffenderProfessionalLicenses.ascx";
                        var userControl10 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderProfessionalLicenses;
                        userControl10.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl10);
                        userControl10.SaveButtonClicked += new EventHandler(NextTab);
                        break;
                    case "pageSchool":
                        userControlName = "~/Ctl/Offenders/OffenderSchool.ascx";
                        var userControl11 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderSchool;
                        userControl11.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl11);
                        userControl11.SaveButtonClicked += new EventHandler(NextTab);
                        userControl11.InitializeValues();
                        break;
                    case "pageVehicle":
                        userControlName = "~/Ctl/Offenders/OffenderVehicles.ascx";
                        var userControl12 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderVehicles;
                        userControl12.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl12);
                        userControl12.SaveButtonClicked += new EventHandler(NextTab);
                        userControl12.InitializeValues();
                        break;
                    case "pageConvictions":
                        userControlName = "~/Ctl/Offenders/OffenderConvictions.ascx";
                        var userControl13 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderConvictions;
                        userControl13.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl13);
                        userControl13.SaveButtonClicked += new EventHandler(NextTab);
                        userControl13.InitializeValues();
                        break;
                    case "pageContact":
                        userControlName = "~/Ctl/Offenders/OffenderContacts.ascx";
                        var userControl14 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderContacts;
                        userControl14.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl14);
                        userControl14.SaveButtonClicked += new EventHandler(NextTab);
                        userControl14.InitializeValues();
                        break;
                    case "pageCrimeDescription":
                        userControlName = "~/Ctl/Offenders/OffenderCrimeDescription.ascx";
                        var userControl15 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderCrimeDescription;
                        userControl15.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl15);
                        userControl15.SaveButtonClicked += new EventHandler(NextTab);
                        userControl15.InitializeValues();
                        break;
                    case "pageCrimes":
                        userControlName = "~/Ctl/Offenders/OffenderCrimes.ascx";
                        var userControl16 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderCrimes;
                        userControl16.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl16);
                        userControl16.SaveButtonClicked += new EventHandler(NextTab);
                        userControl16.InitializeValues();
                        break;
                    case "pageVictim":
                        userControlName = "~/Ctl/Offenders/OffenderVictims.ascx";
                        var userControl17 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderVictims;
                        userControl17.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl17);
                        userControl17.SaveButtonClicked += new EventHandler(NextTab);
                        break;
                    case "pageStatus":
                        userControlName = "~/Ctl/Offenders/OffenderStatus.ascx";
                        var userControl18 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderStatus;
                        userControl18.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl18);
                        userControl18.SaveButtonClicked += new EventHandler(NextTab);
                        userControl18.InitializeValues();
                        break;
                    case "pageCertSign":
                        userControlName = "~/Ctl/Offenders/OffenderCertSign.ascx";
                        var userControl19 = Page.LoadControl(userControlName) as Ctl.Offenders.OffenderCertSign;
                        userControl19.ID = e.PageView.ID + "_userControl";
                        e.PageView.Controls.Add(userControl19);
                        userControl19.SaveButtonClicked += new EventHandler(NextTab);
                        userControl19.InitializeValues();
                        break;
                    default:
                        break;
                }
            }
     
            protected void tabstripOptions_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
            {
                AddPageView(e.Tab);
                // if this is the previous address tab, need to refresh its contents because of possible updates done to the primary address
            }
     
            protected void Page_Load(object sender, EventArgs e)
            {
                // if r is passed in, we are creating a new pending offender from a live one (r is the id of the live offender)
                pdb = new Sor2PendingDbDataContext();
                db = new Sor2DataContext();
                tdb = new Sor2TerminatedDbDataContext();
     
                if (String.IsNullOrEmpty(Request.QueryString["i"]))
                {
                    #region Request.QueryString["i"] is null
                    // new pending record
                    if (!IsPostBack)
                    {
                        // check to see if it is an existing offender
                        if (String.IsNullOrEmpty(Request.QueryString["r"]))
                        {
                            #region Request.QueryString["r"] not passed in
                            // brand new initial registration (not from a live offender)
                            btnContactRegisteringOffice.Visible = false;
     
                            // set the staterefnum
                            var currentRefNum = (from c in pdb.CurrentRecordNumbers select c).First();
     
                            // create the record and initialize
                            thisOffender = new PendingOffender();
                            thisOffender.StateRefNum = "S" + currentRefNum.NextNum++.ToString();
                            thisOffender.Status = "saved";
                            thisOffender.DateEntered = DateTime.Now;
                            thisOffender.OffenderType = "I";
                            thisOffender.Log_MachineId = Request.ServerVariables["REMOTE_ADDR"];
                            thisOffender.Log_ModifiedDate = DateTime.Now;
                            thisOffender.Log_OfficeId = Int32.Parse(HttpContext.Current.Profile.GetPropertyValue("OfficeId").ToString());
                            thisOffender.RegisteringUserId =
                                thisOffender.Log_UserId =
                                    Guid.Parse(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
                            thisOffender.RegisteringAgency = Convert.ToInt32(Session["OfficeId"]);
                            pdb.PendingOffenders.InsertOnSubmit(thisOffender);
                            pdb.SubmitChanges();
                            Session["CurrentPendingOffenderId"] = thisOffender.Id;
                            #endregion
                        }
                        else
                        {
                            #region Request.QueryString["r"] passed in
                            // r passed in - current id of live offender
                            // create a copy of the live record in the pending tables
                            Offender liveOffender =
                                (from o in db.Offenders
                                 where o.Id == Int32.Parse(Request.QueryString["r"])
                                 select o).SingleOrDefault();
                            if (liveOffender != null)
                            {
                                int newPendingOffenderId = SorBll.OffenderFunctions.CreatePendingFromLive(liveOffender);
                                thisOffender =
                                    (from po in pdb.PendingOffenders
                                     where po.Id == newPendingOffenderId
                                     select po).SingleOrDefault();
                                thisOffender.Log_MachineId = Request.ServerVariables["REMOTE_ADDR"];
                                thisOffender.Log_ModifiedDate = DateTime.Now;
                                thisOffender.Log_OfficeId = Int32.Parse(HttpContext.Current.Profile.GetPropertyValue("OfficeId").ToString());
                                thisOffender.RegisteringUserId =
                                    thisOffender.Log_UserId =
                                        Guid.Parse(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
                                thisOffender.DateUpdated = DateTime.Now;
                                pdb.SubmitChanges();
                                Session["CurrentPendingOffenderId"] = thisOffender.Id;
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        // this is a postback on an initial record
                        int offenderId = Convert.ToInt32(Session["CurrentPendingOffenderId"]);
                        thisOffender = (from o in pdb.PendingOffenders where o.Id == offenderId select o).SingleOrDefault();
                    }
                    #endregion
                }
                else
                {
                    #region Request.QueryString["i"] passed in
                    // editing record
                    // querystring["i"] exists
                    int offenderId = Convert.ToInt32(Request.QueryString["i"]);
                    Session["CurrentPendingOffenderId"] = offenderId;
                    thisOffender = (from o in pdb.PendingOffenders where o.Id == offenderId select o).SingleOrDefault();
     
                    #endregion
                }
     
                // done with offender init
                lblStateRefNum.Text = thisOffender.StateRefNum;
     
                // enable appropriate tabs
                RadTab tab = tabstripOptions.FindTabByText("Type");
                Ctl.Offenders.OffenderType ctlType = tab.PageView.FindControl("pageType_userControl") as Ctl.Offenders.OffenderType;
                CheckBox chkRegInitial = ctlType.FindControl("chkRegInitial") as CheckBox;
                CheckBox chkRegRe = ctlType.FindControl("chkRegRe") as CheckBox;
                CheckBox chkRegChanges = ctlType.FindControl("chkRegChanges") as CheckBox;
                CheckBox chkRegEmployment = ctlType.FindControl("chkRegEmployment") as CheckBox;
                CheckBox chkRegFed = ctlType.FindControl("chkRegFed") as CheckBox;
                if (!chkRegInitial.Checked && !chkRegRe.Checked && !chkRegChanges.Checked && !chkRegEmployment.Checked && !chkRegFed.Checked)
                {
                    DisableAllTabsExcept(new string[] { "Type" });
                    tab.Enabled = true;
                    tab.Selected = true;
                    tabstripOptions_TabClick(tabstripOptions, new RadTabStripEventArgs(tab));
                }
                else if (chkRegEmployment.Checked)
                    DisableAllTabsExcept(new string[] { "Type", "School", "Employment", "Cert / Sign" });
                else
                {
                    EnableAllTabs();
                }
            }
     
            private void EnableAllTabs()
            {
                for (int c = 0; c < tabstripOptions.Tabs.Count; c++)
                {
                    tabstripOptions.Tabs[c].Enabled = tabstripOptions.Tabs[c].Visible = true;
                }
            }
     
            private void DisableAllTabs()
            {
                for (int c = 0; c < tabstripOptions.Tabs.Count; c++)
                {
                    tabstripOptions.Tabs[c].Enabled = tabstripOptions.Tabs[c].Visible = false;
                }
            }
     
            private void DisableAllTabsExcept(string[] tabNames)
            {
                DisableAllTabs();
                foreach (string tabName in tabNames)
                {
                    RadTab tab = tabstripOptions.FindTabByText(tabName);
                    if (tab != null)
                        tab.Enabled = tab.Visible = true;
                }
            }
     
            private void DisableAllUtilityWindows()
            {
                winSendEmail.VisibleOnPageLoad = false;
                winPrintPreview.VisibleOnPageLoad = false;
            }
     
            protected void btnContactRegisteringOffice_Click(object sender, EventArgs e)
            {
                int myOfficeId = Int32.Parse(HttpContext.Current.Profile.GetPropertyValue("OfficeId").ToString());
                var myOffice = (from o in pdb.PendingOffices where o.Id == myOfficeId select o).SingleOrDefault();
                winSendEmail.NavigateUrl = "~/Utility/SendEmailForm.aspx?" +
                    "f=" + User.Identity.Name +
                    "&t=" + thisOffender.PendingOffice.OfficeEmailAddress +
                    "&s=Information on Offender: " + thisOffender.StateRefNum +
                    "&b=" +
                    Server.UrlEncode(thisOffender.PendingOffice.OfficeName + ", \n\nThis email message is concerning Sex Offender " +
                        thisOffender.FirstName + " " + thisOffender.LastName + ", State Ref Number: " + thisOffender.StateRefNum +
                        " as follows:\n\n\n\n\nRegards, \n" + myOffice.OfficeName);
                winSendEmail.VisibleOnPageLoad = true;
            }
     
            protected void btnDeleteFromQueue_Click(object sender, EventArgs e)
            {
                pdb.sp_DeletePendingRecord(Convert.ToInt32(Session["CurrentPendingOffenderId"]));
                string script = "function f() { alert('Record Deleted from Queue'); CloseRadWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "key", script, true);
            }
     
            protected void btnPrintPreview_Click(object sender, EventArgs e)
            {
                winPrintPreview.NavigateUrl = "~/Reports/PendingOffenderPrint.aspx";
                winPrintPreview.VisibleOnPageLoad = true;
            }
     
        }
    }
  6. Kevin F
    Kevin F avatar
    46 posts
    Member since:
    Sep 2009

    Posted 25 Oct 2013 Link to this post

    Here is the ASPX and code-behind for the control (tab) that causes everything to go haywire after viewing.  Reminder that I can click through each of the tabs and perform CRUD operations with RadGrids with no issues, until I click on the tab containing this control.  After I click on a tab after this one and try to do the CRUD operations on any other tab, the pageview is blank.

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OffenderEmployment.ascx.cs" Inherits="SdSoia.Ctl.Offenders.OffenderEmployment" %>
     
    <div class="formLine">
        <strong>EMPLOYMENT INFORMATION</strong>
    </div>
    <telerik:RadWindow ID="winCities" runat="server" Behavior="Close, Maximize, Move" Behaviors="Close, Maximize, Move" InitialBehaviors="Maximize"
        DestroyOnClose="True" KeepInScreenBounds="True" Modal="True" ReloadOnShow="true">
    </telerik:RadWindow>
     
    <telerik:RadButton ID="btnAddEmploymentRecord" runat="server" Text="Add Employment Record" OnClick="btnAddEmploymentRecord_Click"></telerik:RadButton>
    <telerik:RadListView ID="lstViewEmployment" runat="server" DataKeyNames="Id" DataSourceID="dsEmployments" AllowPaging="True" AllowCustomPaging="True"
        AllowNaturalSort="True" PageSize="1" Skin="Windows7" OnItemCreated="lstViewEmployment_ItemCreated" OnItemInserted="lstViewEmployment_ItemInserted"
        OnItemUpdated="lstViewEmployment_ItemUpdated" OnItemCanceling="lstViewEmployment_ItemCanceling" OnItemEditing="lstViewEmployment_ItemEditing"
        OnItemDataBound="lstViewEmployment_ItemDataBound">
        <LayoutTemplate>
            <div class="RadListView RadListViewFloated RadListView_Windows7">
                <div class="rlvFloated">
                    <div runat="server" id="itemPlaceholder"></div>
                </div>
                <telerik:RadDataPager runat="server" SEOPagingQueryPageKey="" Skin="Windows7" ID="RadDataPager1" PageSize="1" Width="900">
                    <Fields>
                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                        <telerik:RadDataPagerButtonField FieldType="NextLast" />
                        <telerik:RadDataPagerGoToPageField CurrentPageText="Employment Record" EnableSubmitButton="false" HorizontalPosition="RightFloat" />
                    </Fields>
                </telerik:RadDataPager>
                <div style="display: none">
                    <telerik:RadCalendar runat="server" ID="rlvSharedCalendar" Skin='<%#Container.Skin %>' RangeMinDate='<%#new DateTime(1900, 1, 1) %>' />
                </div>
                <div style="display: none">
                    <telerik:RadTimeView runat="server" ID="rlvSharedTimeView" Skin='<%# Container.Skin %>' />
                </div>
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <div class="rlvI">
                <telerik:RadButton ID="btnEdit" runat="server" Text="Edit" ToolTip="Edit" CommandName="Edit" CausesValidation="false"></telerik:RadButton>
                <telerik:RadButton ID="btnDelete" runat="server" Text="Delete" ToolTip="Delete" CommandName="Delete" CausesValidation="false"></telerik:RadButton>
                <div class="formLine">
                    <div class="formField66">
                        Name of Employer:
                                            <asp:Label ID="lblEmployerName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Employment Address:
                                            <asp:Label ID="lblEmployerAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        City, State:
                                            <asp:Label ID="lblCity" runat="server" Text='<%# Eval("City") %>'></asp:Label>,
                                            <asp:Label ID="lblState" runat="server" Text='<%# Eval("State") %>'></asp:Label>
                    </div>
                    <div class="formField33">
                        County:
                                            <asp:Label ID="lblCounty" runat="server" Text='<%# Eval("County") %>'></asp:Label>
                    </div>
                    <div class="formField33">
                        Zip:
                                            <asp:Label ID="lblZip" runat="server" Text='<%# Eval("ZipCode") %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        Phone Number:
                                            <asp:Label ID="lblPhone" runat="server" Text='<%# SorBll.Util.FormatPhoneNumber(Eval("Phone")) %>'></asp:Label>
                    </div>
                    <div class="formField66">
                        Employment Begin Date:
                                            <asp:Label ID="lblStartDate" runat="server" Text='<%# SorBll.Util.FormatNullableDate(Eval("BeginDate")) %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Occupation:
                                            <asp:Label ID="lblOccupation" runat="server" Text='<%# Eval("Occupation") %>'></asp:Label>
                    </div>
                </div>
            </div>
        </ItemTemplate>
        <AlternatingItemTemplate>
            <div class="rlvA">
                <telerik:RadButton ID="btnEdit" runat="server" Text="Edit" ToolTip="Edit" CommandName="Edit" CausesValidation="false"></telerik:RadButton>
                <telerik:RadButton ID="btnDelete" runat="server" Text="Delete" ToolTip="Delete" CommandName="Delete" CausesValidation="false"></telerik:RadButton>
                <div class="formLine">
                    <div class="formField66">
                        Name of Employer:
                                            <asp:Label ID="lblEmployerName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Employment Address:
                                            <asp:Label ID="lblEmployerAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        City, State:
                                            <asp:Label ID="lblCity" runat="server" Text='<%# Eval("City") %>'></asp:Label>,
                                            <asp:Label ID="lblState" runat="server" Text='<%# Eval("State") %>'></asp:Label>
                    </div>
                    <div class="formField33">
                        County:
                                            <asp:Label ID="lblCounty" runat="server" Text='<%# Eval("County") %>'></asp:Label>
                    </div>
                    <div class="formField33">
                        Zip:
                                            <asp:Label ID="lblZip" runat="server" Text='<%# Eval("ZipCode") %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        Phone Number:
                                            <asp:Label ID="lblPhone" runat="server" Text='<%# SorBll.Util.FormatPhoneNumber(Eval("Phone")) %>'></asp:Label>
                    </div>
                    <div class="formField66">
                        Employment Begin Date:
                                            <asp:Label ID="lblStartDate" runat="server" Text='<%# SorBll.Util.FormatNullableDate(Eval("BeginDate")) %>'></asp:Label>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Occupation:
                                            <asp:Label ID="lblOccupation" runat="server" Text='<%# Eval("Occupation") %>'></asp:Label>
                    </div>
                </div>
            </div>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    function CloseCityPopUpAndRefreshEmploymentEdit() {
                        var combo = $find("<%= lstViewEmployment.EditItems[0].FindControl("cboEmploymentCity").ClientID %>");
                        combo.requestItems("", false);
                    }
                </script>
            </telerik:RadScriptBlock>
            <div class="rlvIEdit">
                <div class="formLine">
                    <div class="formField66">
                        Name of Employer:
                                <telerik:RadTextBox ID="txtEmployerName" runat="server" MaxLength="50" Width="400" Text='<%# Bind("Name") %>'>
                                    <ClientEvents OnBlur="ForceUpperCase" />
                                </telerik:RadTextBox>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Employment Address:
                                <telerik:RadTextBox ID="txtEmployerAddress" runat="server" MaxLength="50" Width="400" Text='<%# Bind("Address") %>'>
                                    <ClientEvents OnBlur="ForceUpperCase" />
                                </telerik:RadTextBox>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        City, State:
                            <asp:LinkButton ID="lnkAddEmploymentCityEdit" runat="server" OnClick="lnkAddEmploymentCityEdit_Click">ADD CITY</asp:LinkButton>
                        |
                            <asp:LinkButton ID="lnkClearCity" runat="server" OnClick="lnkClearCity_Click">CLEAR CITY</asp:LinkButton>
                        <br />
                        <telerik:RadComboBox ID="cboEmploymentCity" runat="server" EmptyMessage="Type city ..." DataValueField="IDNumber"
                            DataTextField="CITY" MarkFirstMatch="true" DropDownAutoWidth="Enabled" OnItemsRequested="cboEmploymentCity_ItemsRequested"
                            EnableLoadOnDemand="true">
                            <ItemTemplate>
                                <%# Eval("CITY") %>, <%# Eval("State") %>, <%# Eval("ZIPCODE1") %>  <%# Eval("COUNTY") %>
                            </ItemTemplate>
                        </telerik:RadComboBox>
                        ,
                                <telerik:RadTextBox ID="txtEmploymentState" runat="server" MaxLength="2" Width="45px" Enabled="false" Text='<%# Bind("State") %>'></telerik:RadTextBox>
                    </div>
                    <div class="formField33">
                        County:<br />
                        <telerik:RadTextBox ID="txtEmploymentCounty" runat="server" MaxLength="50" Enabled="false" Text='<%# Bind("County") %>'></telerik:RadTextBox>
                    </div>
                    <div class="formField33">
                        Zip:<br />
                        <telerik:RadMaskedTextBox ID="txtEmploymentZip" runat="server" Mask="#####" Enabled="false" Text='<%# Bind("ZipCode") %>'></telerik:RadMaskedTextBox>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        Phone Number:<br />
                        <telerik:RadMaskedTextBox ID="txtEmploymentPhoneNumber" runat="server" Mask="(###) ###-####" Columns="15" Text='<%# Bind("Phone") %>'></telerik:RadMaskedTextBox>
                    </div>
                    <div class="formField66">
                        Employment Begin Date:
                                <telerik:RadDatePicker ID="txtEmploymentStartDate" runat="server" MinDate="1/1/1900" SelectedDate='<%# Bind("BeginDate") %>'></telerik:RadDatePicker>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Occupation:
                                <telerik:RadTextBox ID="txtEmploymentOccupation" runat="server" MaxLength="255" Width="400" Text='<%# Bind("Occupation") %>'>
                                    <ClientEvents OnBlur="ForceUpperCase" />
                                </telerik:RadTextBox>
                    </div>
                </div>
                <telerik:RadButton ID="btnUpdate" runat="server" Text="Update" ToolTip="Update" CommandName="Update"></telerik:RadButton>
                <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel" ToolTip="Cancel" CommandName="Cancel" CausesValidation="false"></telerik:RadButton>
            </div>
        </EditItemTemplate>
        <InsertItemTemplate>
            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    function CloseCityPopUpAndRefreshEmploymentInsert() {
                        var combo = $find("<%= lstViewEmployment.InsertItem.FindControl("cboEmploymentCity").ClientID %>");
                        combo.requestItems("", false);
                    }
                </script>
            </telerik:RadScriptBlock>
            <div class="rlvIEdit">
                <div class="formLine">
                    <div class="formField66">
                        Name of Employer:
                                <telerik:RadTextBox ID="txtEmployerName" runat="server" MaxLength="50" Width="400" Text='<%# Bind("Name") %>'>
                                    <ClientEvents OnBlur="ForceUpperCase" />
                                </telerik:RadTextBox>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Employment Address:
                                <telerik:RadTextBox ID="txtEmployerAddress" runat="server" MaxLength="50" Width="400" Text='<%# Bind("Address") %>'>
                                    <ClientEvents OnBlur="ForceUpperCase" />
                                </telerik:RadTextBox>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        City, State:
                            <asp:LinkButton ID="lnkAddEmploymentCityInsert" runat="server" OnClick="lnkAddEmploymentCityInsert_Click">ADD CITY</asp:LinkButton>
                        |
                            <asp:LinkButton ID="lnkClearCity" runat="server" OnClick="lnkClearCity_Click">CLEAR CITY</asp:LinkButton>
                        <br />
                        <telerik:RadComboBox ID="cboEmploymentCity" runat="server" EmptyMessage="Type city ..." DataSourceID="dsCities" DataValueField="IDNumber" DataTextField="CITY"
                            MarkFirstMatch="true" DropDownAutoWidth="Enabled">
                            <ItemTemplate>
                                <%# Eval("CITY") %>, <%# Eval("State") %>, <%# Eval("ZIPCODE1") %>  <%# Eval("COUNTY") %>
                            </ItemTemplate>
                        </telerik:RadComboBox>
                        ,
                                <telerik:RadTextBox ID="txtEmploymentState" runat="server" MaxLength="2" Width="45px" Enabled="false" Text='<%# Bind("State") %>'></telerik:RadTextBox>
                    </div>
                    <div class="formField33">
                        County:<br />
                        <telerik:RadTextBox ID="txtEmploymentCounty" runat="server" MaxLength="50" Enabled="false" Text='<%# Bind("County") %>'></telerik:RadTextBox>
                    </div>
                    <div class="formField33">
                        Zip:<br />
                        <telerik:RadMaskedTextBox ID="txtEmploymentZip" runat="server" Mask="#####" Enabled="false" Text='<%# Bind("ZipCode") %>'></telerik:RadMaskedTextBox>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField33">
                        Phone Number:<br />
                        <telerik:RadMaskedTextBox ID="txtEmploymentPhoneNumber" runat="server" Mask="(###) ###-####" Columns="15" Text='<%# Bind("Phone") %>'></telerik:RadMaskedTextBox>
                    </div>
                    <div class="formField66">
                        Employment Begin Date:
                                <telerik:RadDatePicker ID="txtEmploymentStartDate" runat="server" MinDate="1/1/1900" SelectedDate='<%# Bind("BeginDate") %>'></telerik:RadDatePicker>
                    </div>
                </div>
                <div class="formLine">
                    <div class="formField66">
                        Occupation:
                                <telerik:RadTextBox ID="txtEmploymentOccupation" runat="server" MaxLength="255" Width="400" Text='<%# Bind("Occupation") %>'>
                                    <ClientEvents OnBlur="ForceUpperCase" />
                                </telerik:RadTextBox>
                    </div>
                </div>
                <telerik:RadButton ID="btnInsert" runat="server" Text="Add Employment Record" ToolTip="Add" CommandName="PerformInsert"></telerik:RadButton>
                <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel" ToolTip="Cancel" CommandName="Cancel" CausesValidation="false"></telerik:RadButton>
            </div>
        </InsertItemTemplate>
        <EmptyDataTemplate>
            <div class="RadListView RadListView_Windows7">
                <div class="rlvEmpty">There are no items to be displayed.</div>
            </div>
        </EmptyDataTemplate>
        <SelectedItemTemplate>
            <div class="rlvISel">
                <asp:Button runat="server" CommandName="Deselect" Text=" " ID="DeselectButton" CssClass="rlvBSel" ToolTip="Deselect" CausesValidation="False" />
                <asp:Button runat="server" CommandName="Delete" Text=" " ID="DeleteButton" CssClass="rlvBDel" ToolTip="Delete" CausesValidation="False" />
                <asp:Button runat="server" CommandName="Edit" Text=" " ID="EditButton" CssClass="rlvBEdit" ToolTip="Edit" CausesValidation="False" />
                <br />
                <asp:Label Text='<%# Eval("Id") %>' runat="server" ID="IdLabel" />
                <br />
                <asp:Label Text='<%# Eval("OffenderId") %>' runat="server" ID="OffenderIdLabel" />
                <br />
                <asp:Label Text='<%# Eval("Name") %>' runat="server" ID="NameLabel" />
                <br />
                <asp:Label Text='<%# Eval("Address") %>' runat="server" ID="AddressLabel" />
                <br />
                <asp:Label Text='<%# Eval("City") %>' runat="server" ID="CityLabel" />
                <br />
                <asp:Label Text='<%# Eval("County") %>' runat="server" ID="CountyLabel" />
                <br />
                <asp:Label Text='<%# Eval("State") %>' runat="server" ID="StateLabel" />
                <br />
                <asp:Label Text='<%# Eval("ZipCode") %>' runat="server" ID="ZipCodeLabel" />
                <br />
                <asp:Label Text='<%# Eval("Phone") %>' runat="server" ID="PhoneLabel" />
                <br />
                <asp:Label Text='<%# Eval("BeginDate") %>' runat="server" ID="BeginDateLabel" />
                <br />
                <asp:Label Text='<%# Eval("Occupation") %>' runat="server" ID="OccupationLabel" />
                <br />
                <asp:Label Text='<%# Eval("PendingOffender") %>' runat="server" ID="PendingOffenderLabel" />
            </div>
        </SelectedItemTemplate>
    </telerik:RadListView>
    <asp:LinqDataSource runat="server" EntityTypeName="" ID="dsEmployments" ContextTypeName="SorDal.Sor2PendingDbDataContext"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" OrderBy="Id" TableName="PendingOffenderEmployers" Where="OffenderId == @OffenderId"
        OnInserting="dsEmployments_Inserting" OnUpdating="dsEmployments_Updating">
        <WhereParameters>
            <asp:SessionParameter SessionField="CurrentPendingOffenderId" Name="OffenderId" Type="Int32"></asp:SessionParameter>
        </WhereParameters>
        <InsertParameters>
            <asp:SessionParameter SessionField="CurrentPendingOffenderId" Name="OffenderId" Type="Int32"></asp:SessionParameter>
        </InsertParameters>
    </asp:LinqDataSource>
    <div class="formLine">
        <hr />
    </div>
    <div class="formLine">
        <telerik:RadButton ID="btnSave" runat="server" Text="Save and Continue" OnClick="btnSaveEmployment_Click"></telerik:RadButton>
    </div>
    <asp:LinqDataSource runat="server" EntityTypeName="" ID="dsCities" ContextTypeName="SorDal.Sor2DataContext" OrderBy="CITY" TableName="ZipCodes"></asp:LinqDataSource>

    Code Behind:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using SorDal;
    using Telerik.Web.UI;
     
    namespace SdSoia.Ctl.Offenders
    {
        public partial class OffenderEmployment : System.Web.UI.UserControl
        {
            private Sor2PendingDbDataContext pdb = new Sor2PendingDbDataContext();
            private Sor2DataContext db = new Sor2DataContext();
     
            private int offenderId
            {
                get
                {
                    return Convert.ToInt32(Session["CurrentPendingOffenderId"]);
                }
                set
                {
                    offenderId = value;
                }
            }
     
            public PendingOffender thisOffender;
     
            public event EventHandler SaveButtonClicked;
     
            private void OnSaveButtonClick()
            {
                if (SaveButtonClicked != null)
                {
                    SaveButtonClicked(this, EventArgs.Empty);
                }
            }
     
            public void InitializeValues()
            {
                //thisOffender = (from p in pdb.PendingOffenders where p.Id == offenderId select p).SingleOrDefault();
            }
     
            protected void btnAddEmploymentRecord_Click(object sender, EventArgs e)
            {
                lstViewEmployment.InsertItemPosition = RadListViewInsertItemPosition.FirstItem;
                lstViewEmployment.ShowInsertItem();
                btnAddEmploymentRecord.Enabled = false;
                DisableUtilityWindows();
            }
     
            protected void lnkAddEmploymentCityEdit_Click(object sender, EventArgs e)
            {
                winCities.NavigateUrl = "~/Utility/CityPopup.aspx";
                winCities.VisibleOnPageLoad = true;
                winCities.OnClientClose = "CloseCityPopUpAndRefreshEmploymentEdit";
            }
     
            protected void btnSaveEmployment_Click(object sender, EventArgs e)
            {
                DisableUtilityWindows();
                OnSaveButtonClick();
            }
     
            protected void lstViewEmployment_ItemCreated(object sender, RadListViewItemEventArgs e)
            {
                RadComboBox cbo = e.Item.FindControl("cboEmploymentCity") as RadComboBox;
                if (cbo != null)
                {
                    cbo.AutoPostBack = true;
                    cbo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cboEmploymentCity_SelectedIndexChanged);
                }
            }
     
            protected void cboEmploymentCity_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
            {
                RadComboBox cbo = sender as RadComboBox;
                RadListViewDataItem dItem = cbo.NamingContainer as RadListViewDataItem;
                 
                RadTextBox txtEmploymentCounty = dItem.FindControl("txtEmploymentCounty") as RadTextBox;
                RadTextBox txtEmploymentState = dItem.FindControl("txtEmploymentState") as RadTextBox;
                RadMaskedTextBox txtEmploymentZip = dItem.FindControl("txtEmploymentZip") as RadMaskedTextBox;
                int addressId = 0;
                if (Int32.TryParse(e.Value, out addressId))
                {
                    var addressInfo =
                        (from z in db.ZipCodes where z.IDNumber == addressId select z).SingleOrDefault();
                    txtEmploymentCounty.Text = addressInfo.COUNTY;
                    txtEmploymentState.Text = addressInfo.State;
                    txtEmploymentZip.Text = addressInfo.ZIPCODE1;
                }
                else
                {
                    txtEmploymentCounty.Text = string.Empty;
                    txtEmploymentState.Text = string.Empty;
                    txtEmploymentZip.Text = string.Empty;
                }
                DisableUtilityWindows();
            }
     
            protected void lstViewEmployment_ItemInserted(object sender, RadListViewInsertedEventArgs e)
            {
                btnAddEmploymentRecord.Enabled = true;
            }
     
            protected void lstViewEmployment_ItemUpdated(object sender, RadListViewUpdatedEventArgs e)
            {
                btnAddEmploymentRecord.Enabled = true;
            }
     
            protected void lstViewEmployment_ItemCanceling(object sender, RadListViewCommandEventArgs e)
            {
                btnAddEmploymentRecord.Enabled = true;
            }
     
            protected void lstViewEmployment_ItemEditing(object sender, RadListViewCommandEventArgs e)
            {
                btnAddEmploymentRecord.Enabled = false;
            }
     
            protected void dsEmployments_Inserting(object sender, LinqDataSourceInsertEventArgs e)
            {
                RadComboBox cboEmploymentCity = lstViewEmployment.InsertItem.FindControl("cboEmploymentCity") as RadComboBox;
                 
                (e.NewObject as PendingOffenderEmployer).City = cboEmploymentCity.Text;
            }
     
            protected void dsEmployments_Updating(object sender, LinqDataSourceUpdateEventArgs e)
            {
                RadComboBox cboEmploymentCity = lstViewEmployment.EditItems[0].FindControl("cboEmploymentCity") as RadComboBox;
                (e.NewObject as PendingOffenderEmployer).City = cboEmploymentCity.Text;
            }
     
            protected void lstViewEmployment_ItemDataBound(object sender, RadListViewItemEventArgs e)
            {
                if (e.Item is RadListViewEditableItem)
                {
                    RadListViewEditableItem item = e.Item as RadListViewEditableItem;
                    RadComboBox cboEmploymentCity = item.FindControl("cboEmploymentCity") as RadComboBox;
                    PendingOffenderEmployer emp = item.DataItem as PendingOffenderEmployer;
                    cboEmploymentCity.Text = emp.City;
                }
     
            }
     
            protected void lnkClearCity_Click(object sender, EventArgs e)
            {
                if (lstViewEmployment.EditItems.Count > 0)
                {
                    RadComboBox city = lstViewEmployment.EditItems[0].FindControl("cboEmploymentCity") as RadComboBox;
                    RadTextBox state = lstViewEmployment.EditItems[0].FindControl("txtEmploymentState") as RadTextBox;
                    RadMaskedTextBox zip = lstViewEmployment.EditItems[0].FindControl("txtEmploymentZip") as RadMaskedTextBox;
                    RadTextBox county = lstViewEmployment.EditItems[0].FindControl("txtEmploymentCounty") as RadTextBox;
                    city.SelectedIndex = -1;
                    city.Text = string.Empty;
                    state.Text = string.Empty;
                    zip.Text = string.Empty;
                    county.Text = string.Empty;
                }
                else
                {
                    RadComboBox city = lstViewEmployment.InsertItem.FindControl("cboEmploymentCity") as RadComboBox;
                    RadTextBox state = lstViewEmployment.InsertItem.FindControl("txtEmploymentState") as RadTextBox;
                    RadMaskedTextBox zip = lstViewEmployment.InsertItem.FindControl("txtEmploymentZip") as RadMaskedTextBox;
                    RadTextBox county = lstViewEmployment.InsertItem.FindControl("txtEmploymentCounty") as RadTextBox;
                    city.SelectedIndex = -1;
                    city.Text = string.Empty;
                    state.Text = string.Empty;
                    zip.Text = string.Empty;
                    county.Text = string.Empty;
                }
            }
     
            protected void lstViewEmployment_PageIndexChanged(object sender, RadListViewPageChangedEventArgs e)
            {
                DisableUtilityWindows();
            }
     
            protected void lnkAddEmploymentCityInsert_Click(object sender, EventArgs e)
            {
                winCities.NavigateUrl = "~/Utility/CityPopup.aspx";
                winCities.VisibleOnPageLoad = true;
                winCities.OnClientClose = "CloseCityPopUpAndRefreshEmploymentInsert";
            }
     
            protected void cboEmploymentCity_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
            {
                RadComboBox combo = sender as RadComboBox;
                combo.DataSourceID = "dsCities";
                combo.DataBind();
                DisableUtilityWindows();
            }
     
            private void DisableUtilityWindows()
            {
                winCities.VisibleOnPageLoad = false;
            }
        }
    }
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 29 Oct 2013 Link to this post

    Hi Kevin,

    I don't see the declaration of your RadGrids and I suppose they are in the user controls.
    Loading UserControl that contains grid should happen no later than Page_Load in the Page Life Cycle
    PageViewCreated event is too late, and this is the reason the grid inside your user control could not be rendered properly.

    Regards,
    Vasil
    Telerik
    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 the blog feed now.
  8. Kevin F
    Kevin F avatar
    46 posts
    Member since:
    Sep 2009

    Posted 29 Oct 2013 Link to this post

    Where would you recommend I load the controls into the page view?  The dynamic tab examples I have seen have loaded them there.

    I moved the loading into the tabstrip_onclick event and now the onclick event attached to a button inside the control won't fire. 

    Thanks!!

    Kevin
  9. Kevin F
    Kevin F avatar
    46 posts
    Member since:
    Sep 2009

    Posted 29 Oct 2013 Link to this post

    My apologies.  I have wasted everyone's time here.  There was a single line in the code loading the control on the particular problem tab causing its pageview to be selected.  Only took me 50 hours to find it.

    Again, my sincere apologies.

    Kevin
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017