1

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:

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.

Felicia Soh
  • 815
  • 3
  • 18
  • 32

1 Answers1

1
  1. Get TabPanel from client code. This is sample code:
var tabContainer = $find("Content_DemoContent_Tabs");
for(var i = 0; i < tabContainer.get_tabs().length; i++)
{
    tabContainer.set_activeTabIndex(i);
    var element = tabContainer.get_tabs()[i]._element;
}
  1. Calculate position of each element in screen coordinates. This is quite complex and not reliable task, but you can see how to do it here: https://stackoverflow.com/a/21274679/644496
  2. Send this data to server to make a screenshot. This is broad, though well-know task, so you can choose any way of doing it.
Community
  • 1
  • 1
Mikhail Tymchuk
  • 886
  • 4
  • 8