Click here to Skip to main content
15,888,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all,

i try to loop through each tab panel in Ajax tab container, then draw the tab panel to bitmap, and save the image. But there's a problem faced here (Please See: http://i.stack.imgur.com/Mgws1.png[^].

I was unable to set tab panel's client size, client rectangle and draw tab panel to bitmap.

This is my codes to bitmap tab panel in tab container:
C#
foreach (object obj in container.Controls)
                {
                    if (obj is AjaxControlToolkit.TabPanel)
                    {
                        AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj;
                        using (Bitmap bmp = new Bitmap(tabPanel.ClientSize.Width, tabPanel.ClientSize.Height))
                    {
                            tabPanel.DrawToBitmap(bmp, tabPanel.ClientRectangle);
                        bmp.Save(CapturedFilePath + tabPanel.Name + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }


This is my code to create tab and tab container dynamically in C#:
C#
AjaxControlToolkit.TabContainer container = new AjaxControlToolkit.TabContainer();
            container.ID = "TabContainer";
            container.EnableViewState = false;
            container.Tabs.Clear();
            container.Height = Unit.Pixel(1000);
            container.Width = Unit.Percentage(100);

            if (Listbox1.SelectedValue == "Select All")    //If 'Select All' option is selected from Listbox1
            {
                foreach (ListItem item in Listbox1.Items)
                {
                    if (item.Text == "Select All")
                    {
                        continue;
                    }
                    AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel(); //creating dynamic tabs
                    panel.HeaderText += item.Text;
                    container.Tabs.Add(panel);

Question: How to Bitmap Tab Panel From Ajax Tab Container Using C#?

Appreciate if someone could guide me on this, thanks!
Posted
Updated 20-Oct-15 6:48am
v2

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