Not switches to the next tab When Next button is clicked

3 posts, 0 answers
  1. Nilachandan
    Nilachandan avatar
    18 posts
    Member since:
    Jul 2008

    Posted 13 Oct 2008 Link to this post

    Hi Telerik
    I am creating Dynamic Rad Strip which is having 3 Rad Tabs namely "Newly Added", "Popular", "Create New". Now I have one button in Rad Tab1(Newly Added) by clicking which, I want to be in Rad Tab3(Create New) enable. I am following your "Wizard" example that switches to the next tab. But in my case, when I am hitting the Button the Error "Object reference not set to an instance of an object" is giving in the line having red color.

    private void GoToNextTab()
        {
            try
            {
                RadTabStrip tabStrip = (RadTabStrip)Page.FindControl("ForumRadTabStrip");
                RadTab professionalInfoTab = tabStrip.FindTabByText("Create New");          
                //LinkButton1.Text = tabStrip.FindTabByText("Newly Added").Text;            
                //professionalInfoTab.Enabled = true;
                //professionalInfoTab.Selected = true;
            }
            catch (Exception ex)
            {
                LinkButton1.Text = ex.Message;
            }
        }

    Why this is happening?
    Regards,
    Chandan
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2008 Link to this post

    Hey Chandan,

    Hmm, the code you gave down there is working just as expected.  I'm able to set the current tab to professionalInfoTab, create a new tab based on it, etc, etc...  My best guess is there is an issue in the code that creates the tabstrip/multipage dynamically.  Would you be able to post that code so we can troubleshoot it?

    Also, just curious, are you creating the objects server-side or client-side?  Although I guess seeing the code will answer that one. :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nilachandan
    Nilachandan avatar
    18 posts
    Member since:
    Jul 2008

    Posted 17 Oct 2008 Link to this post

    Hi Serrin

    Thank you for help. I think, I should post all the three pages in which my code lies. those three pages namely Default.aspx, PersonalCs.ascx and ProfessionalCS.ascx.

    The codes for Default.aspx is as follows

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadDockLayout ID="RadDockLayout1" Runat="server" Skin="Office2007">
    <telerik:RadDockZone ID="RadDockZone1" Runat="server" Height="300px" Width="400px">
    <telerik:RadDock ID="RadDock1" Runat="server" Width="300px">
    <ContentTemplate>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" CssClass="tabStrip" 
    MultiPageID="RadMultiPage1" SelectedIndex="0" Skin="Hay">
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" CssClass="multiPage" 
    OnPageViewCreated="RadMultiPage1_PageViewCreated" SelectedIndex="0">
    </telerik:RadMultiPage>
    </ContentTemplate>
    </asp:UpdatePanel>
    </ContentTemplate>
    </telerik:RadDock>
    </telerik:RadDockZone>
    </telerik:RadDockLayout>

    Page behind page default.aspx.cs is as follows

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                AddTab("Personal Info", true);

                RadPageView pageView = new RadPageView();
                pageView.ID = "Personal";
                RadMultiPage1.PageViews.Add(pageView);
                AddTab("Education Info", true);
                AddTab("Professional Info", true);
            }
        }
        private void AddTab(string tabName, bool enabled)
        {
            RadTab tab = new RadTab(tabName);
            tab.Enabled = enabled;
            RadTabStrip1.Tabs.Add(tab);
        }

        protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            Control pageViewContents = LoadControl(e.PageView.ID + "CS.ascx");
            pageViewContents.ID = e.PageView.ID + "userControl";
            e.PageView.Controls.Add(pageViewContents);
        }
    }

    The codes for PersonalCs.ascx is as follows:

    <div class="buttonSeparator">
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    <asp:Button runat="server" ID="nextButton" Text="Next" OnClick="nextButton_Click"  CssClass="nextButton" />

    Page behind page PersonalCs.ascx.cs is as follows:

    public partial class PersonalCS : System.Web.UI.UserControl
    {
    protected void Page_Load(object sender, System.EventArgs e)
    {

    }
    protected void nextButton_Click(object sender, EventArgs e)
    {
    UpdatePreview();
    GoToNextTab();
    }

    private void GoToNextTab()
    {
                try
                {
                    RadTabStrip tabStrip = (RadTabStrip)Page.FindControl("RadTabStrip1");
                    Label1.Text = tabStrip.ID.ToString();
                    Label1.Text=tabStrip.ClientID.ToString();
                    RadTab educationInfoTab = tabStrip.FindTabByText("Education Info");
                    educationInfoTab.Enabled = true;
                    educationInfoTab.Selected = true;
                    GoToNextPageView();
                }
                catch (Exception ex)
                {
                    Label1.Text = ex.Message;
                }
    }

    private void GoToNextPageView()
    {
    RadMultiPage multiPage = (RadMultiPage)Page.FindControl("RadMultiPage1");
    RadPageView educationInfoPageView = multiPage.FindPageViewByID("Education");
    if (educationInfoPageView == null)
    {
    educationInfoPageView = new RadPageView();
    educationInfoPageView.ID = "Education";
    multiPage.PageViews.Add(educationInfoPageView);
    }
    educationInfoPageView.Selected = true;
    }

    private void UpdatePreview()
    {
    Control previewControl = Page.FindControl("previewControl");
    }
    }

    The whole thing works fine, if don't put the RadTabStrip inside a RadDock.
    Regards,
    Chandan
Back to Top