Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends,

I am creating Dynamic Tabs in web page. Tabs header and content are coming from database.

Sometimes my tab content has more in length so it increases the height of my tabpanel and it changes the alignment of other components on the page.

I want a scrollbar so that if the content goes more than the specific height then it will show the vertical scrollbar.

MY Problem Is:

I have tried a JQuery scroller for same but as my tabs are dynamically generating(i.e from database) but it never works for dynamically generated tabs. (It works for static div but not in tabs)

I Think following situation may creating the problem..I don't know whether it is right or wrong.
when my tabs get created it attaches Tabcontainername to Tabpanel so the tabpanel name changes in runtime. I think it creates a problem for JQuery to create Scroller at run time.

Can anybody suggest me how to do it????

Thanks in advance.
Shailesh Junghare.
Posted

1 solution

Hi,
you can do something like this to set the scrollbar


C#
 AjaxControlToolkit.TabContainer tcMain = new AjaxControlToolkit.TabContainer();
            tcMain.ID = "tcMain";
            string strTabName = "";
            try
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    short i = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        strTabName = dr["tab_name"].ToString();
                        AjaxControlToolkit.TabPanel tpNew = new AjaxControlToolkit.TabPanel();
                        tpNew.ID="tb" + strTabName;
                        tpNew.TabIndex = i;
                        tpNew.HeaderText = strTabName;
                        Panel pnlNew = new Panel();


                        pnlNew.ScrollBars = ScrollBars.Vertical;


                        
                        LiteralControl lcIframe = new LiteralControl();
                        lcIframe.Text = "<iframe name="" + strTabName + "" height="100%" width="100%" border="0" hold=" />                                        " frameborder="0" src="tabs/" + dr["file_path"].ToString() + <br mode="hold" />                                        dr["tab_main_page"].ToString() + "">test</iframe>";
                        pnlNew.Controls.Add(lcIframe);
                        tpNew.Controls.Add(pnlNew);
                        tcMain.Tabs.Add(tpNew);
                        i++;
                    }
                }
            }
catch (Exception ex)
            {   
                throw ex;
            }
        }


Let me know if you face any issue
 
Share this answer
 
Comments
saj_21 28-Jan-12 8:03am    
thank you Aradhana. I'll give this a try and report my results.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900