Click here to Skip to main content
15,888,221 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hi Members,

I have ajax tab container that contains many tabs. I want to loop through each tab and draw the tab panel content to bitmap.

This is my current codes:
C#
foreach (object obj in container.Controls)
                {
                    if (obj is AjaxControlToolkit.TabPanel)
                    {
                        AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj;

                        Bitmap m_Bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                        Graphics graphics = Graphics.FromImage(m_Bitmap as System.Drawing.Image);
                        graphics.CopyFromScreen(25, 25, 25, 25, m_Bitmap.Size);

                        m_Bitmap.Save(@"C:\Users\user\Desktop\Project\Project1\Source Code\Project1\Image\" + tabPanel.HeaderText + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }

Now I am able to loop thorugh each tab panel in the tab container and screenshot the whole webpage, then save the bitmap image in Image folder. But I want to screenshot/bitmap just the tab panel content.

Question: How to Draw AjaxControlToolkit TabPanel to Bitmap with my current codes?

Please guide me on this, thanks.
Posted

1 solution

You can convert any DOM objects to image.
Check this article for details and demo
Convert (Export) HTML DIV or Table to Image using HTML Canvas in ASP.Net using C# and VB.Net[^]

Hope, it helps :)
 
Share this answer
 

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