how to change the tab title at runtime?

4 posts, 0 answers
  1. sourabh tewari
    sourabh tewari avatar
    4 posts
    Member since:
    Apr 2010

    Posted 01 Jun 2010 Link to this post

    Well I am trying to change the tab heading titles programmatically at runtime...just trying out the trial version...I am new...so please don't mind my ignorance...I tried to search but in vain.Everytime I tried to change the text property of the radtab from code behind...I end up with an object null reference error...lemme tell you what I tried...I need to know as to how do we set the title of a tab at runtime without ending up with an "Object reference not set to an instance of an object." error.


    public partial class JobseekerHome : BasePage 
        #region RadStripBar 
        protected override void Page_Load(object sender, System.EventArgs e) 
        { 
            if (!Page.IsPostBack) 
            { 
                AddTab("LanguageUC""Mini profile"); 
                AddPageView(RadTabStrip1.FindTabByText("LanguageUC")); 
                AddTab("OrdersCS""Experience"); 
                AddTab("ProjectUC""Experience"); 
            } 
        } 
     
        private void AddTab(string tabValue, string tabName) 
        { 
            RadTab tab = new RadTab(); 
            tab.Text = tabValue; 
            tab.Value = tabName; 
            RadTabStrip1.Tabs.Add(tab); 
        } 
     
        protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e) 
        { 
            string userControlName = e.PageView.ID + ".ascx"
     
            Control userControl = Page.LoadControl(userControlName); 
            userControl.ID = e.PageView.ID + "_userControl"
     
            e.PageView.Controls.Add(userControl); 
            e.PageView.FindControl(RadTabStrip1.FindTabByText("LanguageUC").Text="Language"); 
            e.PageView.FindControl(RadTabStrip1.FindTabByText("OrdersCS").Text = "Orders"); 
        } 
     
        private void AddPageView(RadTab tab) 
        { 
            RadPageView pageView = new RadPageView(); 
            pageView.ID = tab.Text; 
            RadMultiPage1.PageViews.Add(pageView); 
            pageView.CssClass = "pageView"
            tab.PageViewID = pageView.ID; 
        } 
     
        protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e) 
        { 
            AddPageView(e.Tab); 
            e.Tab.PageView.Selected = true
        } 
        #endregion 

  2. sourabh tewari
    sourabh tewari avatar
    4 posts
    Member since:
    Apr 2010

    Posted 02 Jun 2010 Link to this post

    I have fixed my problem.
  3. Alfonso
    Alfonso avatar
    3 posts
    Member since:
    Apr 2015

    Posted 11 Mar Link to this post

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["Codigo"] == null)
                {
                    //Response.Redirect(Common.NavegacionWeb.Entrada);
                }
                Session["Validate"] = true;
                AddTab("SolicitudCmp","Solicitud");
                AddPageView(rdtbstrmenu.FindTabByValue("SolicitudCmp"));
                AddTab("Contrato","Contrato / Orden de Compra");
                //AddTab("Contrato");
            }

            if (Session["flagValidate"] != null)
            {
                if (((bool?)Convert.ToBoolean(Session["flagValidate"])) == false)
                {
                    //Validate();
                    Page.Validate("Diligenciamiento");
                    Page.Validate("Location");
                    this.UpdatePanelCuerpo.Update();
                }
                else
                {
                    if (((bool?)Convert.ToBoolean(Session["Validate"])) == true)
                    {
                    }
                    else
                    {
                        //Validate();
                        Page.Validate("Diligenciamiento");
                        Page.Validate("Location");
                        this.UpdatePanelCuerpo.Update();
                    }
                }
            }
        }
        private void AddTab(string tabValue, string tabName)
        {
            RadTab tab = new RadTab();
            tab.Text = tabName;
            tab.Value = tabValue;
            tab.Width = Unit.Pixel(200);
            rdtbstrmenu.Tabs.Add(tab);
        }
        protected void rdmltpgmenu_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {        
            string userControlName = "~/Controls/" + e.PageView.ID + ".ascx";
            Control userControl = Page.LoadControl(userControlName);
            userControl.ID = e.PageView.ID + "_userControl";

            e.PageView.Controls.Add(userControl);
        }
        private void AddPageView(RadTab tab)
        {
            RadPageView pageView = new RadPageView();
            pageView.ID = tab.Value;
            pageView.CssClass = "contentWrapper" + tab.Index;
            rdmltpgmenu.PageViews.Add(pageView);
            tab.PageViewID = pageView.ID;
        }
        protected void rdtbstrmenu_TabClick(object sender, RadTabStripEventArgs e)
        {
            AddPageView(e.Tab);
            e.Tab.PageView.Selected = true;
        }
  4. Alfonso
    Alfonso avatar
    3 posts
    Member since:
    Apr 2015

    Posted 11 Mar Link to this post

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["Codigo"] == null)
                {
                    //Response.Redirect(Common.NavegacionWeb.Entrada);
                }
                Session["Validate"] = true;
                AddTab("SolicitudCmp","Solicitud");
                AddPageView(rdtbstrmenu.FindTabByValue("SolicitudCmp"));
                AddTab("Contrato","Contrato / Orden de Compra");
                //AddTab("Contrato");
            }
     
            if (Session["flagValidate"] != null)
            {
                if (((bool?)Convert.ToBoolean(Session["flagValidate"])) == false)
                {
                    //Validate();
                    Page.Validate("Diligenciamiento");
                    Page.Validate("Location");
                    this.UpdatePanelCuerpo.Update();
                }
                else
                {
                    if (((bool?)Convert.ToBoolean(Session["Validate"])) == true)
                    {
                    }
                    else
                    {
                        //Validate();
                        Page.Validate("Diligenciamiento");
                        Page.Validate("Location");
                        this.UpdatePanelCuerpo.Update();
                    }
                }
            }
        }
        private void AddTab(string tabValue, string tabName)
        {
            RadTab tab = new RadTab();
            tab.Text = tabName;
            tab.Value = tabValue;
            tab.Width = Unit.Pixel(200);
            rdtbstrmenu.Tabs.Add(tab);
        }
        protected void rdmltpgmenu_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {       
            string userControlName = "~/Controls/" + e.PageView.ID + ".ascx";
            Control userControl = Page.LoadControl(userControlName);
            userControl.ID = e.PageView.ID + "_userControl";
     
            e.PageView.Controls.Add(userControl);
        }
        private void AddPageView(RadTab tab)
        {
            RadPageView pageView = new RadPageView();
            pageView.ID = tab.Value;
            pageView.CssClass = "contentWrapper" + tab.Index;
            rdmltpgmenu.PageViews.Add(pageView);
            tab.PageViewID = pageView.ID;
        }
        protected void rdtbstrmenu_TabClick(object sender, RadTabStripEventArgs e)
        {
            AddPageView(e.Tab);
            e.Tab.PageView.Selected = true;
        }
Back to Top