This is a migrated thread and some comments may be shown as answers.

how to change the tab title at runtime?

3 Answers 179 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
sourabh tewari
Top achievements
Rank 1
sourabh tewari asked on 01 Jun 2010, 05:16 PM
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 

3 Answers, 1 is accepted

Sort by
0
sourabh tewari
Top achievements
Rank 1
answered on 02 Jun 2010, 06:26 AM
I have fixed my problem.
0
Alfonso
Top achievements
Rank 1
answered on 12 Mar 2017, 04:17 AM
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;
    }
0
Alfonso
Top achievements
Rank 1
answered on 12 Mar 2017, 04:22 AM
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;
    }
Tags
TabStrip
Asked by
sourabh tewari
Top achievements
Rank 1
Answers by
sourabh tewari
Top achievements
Rank 1
Alfonso
Top achievements
Rank 1
Share this question
or